commit f6fdea5355793cd014da1da68ebd2970eee8f126 Author: Allen Webster Date: Fri Sep 29 18:17:40 2023 -0700 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79a9eda --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +test_data/input_data/*.4id + diff --git a/dist_files/4coder_fleury/bindings.4coder b/dist_files/4coder_fleury/bindings.4coder new file mode 100644 index 0000000..39b8acb --- /dev/null +++ b/dist_files/4coder_fleury/bindings.4coder @@ -0,0 +1,219 @@ + +keys_global = +{ + // NOTE(rjf): Meta + { "exit_4coder" , "F4", "Alt" }, + { "keyboard_macro_start_recording" , "U", "Control" }, + { "keyboard_macro_finish_recording", "U", "Control", "Shift" }, + { "keyboard_macro_replay", "U", "Alt" }, + { "change_active_panel", "Comma", "Control" }, + { "change_active_panel_backwards", "Comma", "Control", "Shift" }, + { "project_go_to_root_directory", "H", "Control" }, + { "f4_toggle_compilation_expand", "Insert" }, + { "change_to_build_panel", "Period", "Alt" }, + { "close_build_panel", "Comma", "Alt" }, + { "f4_switch_syntax_option", "Tick", "Control" }, + + // NOTE(rjf): Files + { "interactive_new", "N", "Control" }, + { "f4_setup_new_project", "N", "Control", "Shift" }, + { "interactive_open_or_new", "O", "Control" }, + { "f4_interactive_open_or_new_in_project", "O", "Alt" }, + { "f4_open_project", "O", "Control", "Shift" }, + { "interactive_kill_buffer", "K", "Control" }, + { "interactive_switch_buffer", "I", "Control" }, + { "save_all_dirty_buffers", "S", "Control", "Shift" }, + { "f4_recent_files_menu", "V", "Alt" }, + + // NOTE(rjf): Jump Lists + { "goto_next_jump", "N", "Alt" }, + { "goto_prev_jump", "N", "Alt", "Shift" }, + { "goto_first_jump", "M", "Alt", "Shift" }, + + // NOTE(rjf): Commands + { "execute_any_cli", "Z", "Alt" }, + { "execute_previous_cli", "Z", "Alt", "Shift" }, + { "command_lister", "X", "Alt" }, + + // NOTE(rjf): Project + { "build_in_build_panel", "M", "Alt" }, + { "project_command_lister", "X", "Alt", "Shift" }, + { "project_fkey_command", "F1", "Control" }, + { "project_fkey_command", "F2", "Control" }, + { "project_fkey_command", "F3", "Control" }, + { "project_fkey_command", "F4", "Control" }, + { "project_fkey_command", "F5", "Control" }, + { "project_fkey_command", "F6", "Control" }, + { "project_fkey_command", "F7", "Control" }, + { "project_fkey_command", "F8", "Control" }, + { "project_fkey_command", "F9", "Control" }, + { "project_fkey_command", "F10", "Control" }, + { "project_fkey_command", "F11", "Control" }, + { "project_fkey_command", "F12", "Control" }, + { "project_fkey_command", "F13", "Control" }, + { "project_fkey_command", "F14", "Control" }, + { "project_fkey_command", "F15", "Control" }, + { "project_fkey_command", "F16", "Control" }, + + // NOTE(rjf): Panels + { "open_panel_vsplit", "P", "Control" }, + { "open_panel_hsplit", "Minus", "Control" }, + { "close_panel", "P", "Control", "Shift" }, + { "f4_search_for_definition__project_wide", "J", "Control" }, + { "f4_search_for_definition__current_file", "J", "Control", "Shift" }, + { "jump_to_last_point", "J", "Alt" }, + +}; + +keys_file = +{ + // NOTE(rjf): None => Characters + // Ctrl => Tokens + // Alt => Alphanumeric/Camel + + // NOTE(rjf): Backspace/Delete + { "delete_char", "Delete" }, + { "f4_delete_token_boundary", "Delete", "Control" }, + { "f4_delete_alpha_numeric_or_camel_boundary", "Delete", "Alt" }, + { "backspace_char", "Backspace" }, + { "f4_backspace_token_boundary", "Backspace", "Control" }, + { "f4_backspace_alpha_numeric_or_camel_boundary", "Backspace", "Alt" }, + + // NOTE(rjf): Left/Right Arrow Keys + { "f4_move_left", "Left" }, + { "f4_move_left_token_boundary", "Left", "Control" }, + { "move_left_alpha_numeric_or_camel_boundary", "Left", "Alt" }, + { "f4_move_right", "Right" }, + { "f4_move_right_token_boundary", "Right", "Control" }, + { "move_right_alpha_numeric_or_camel_boundary", "Right", "Alt" }, + + // NOTE(rjf): Up/Down Arrow Keys + { "move_up", "Up" }, + { "move_down", "Down" }, + { "move_up_to_blank_line_end", "Up", "Control" }, + { "move_down_to_blank_line_end", "Down", "Control" }, + { "move_line_up", "Up", "Alt" }, + { "move_line_down", "Down", "Alt" }, + { "f4_move_to_prev_divider_comment", "Up", "Control", "Shift" }, + { "f4_move_to_next_divider_comment", "Down", "Control", "Shift" }, + { "f4_move_up_token_occurrence", "Up", "Control", "Alt" }, + { "f4_move_down_token_occurrence", "Down", "Control", "Alt" }, + + // NOTE(rjf): Alternative Movement Keys + { "seek_end_of_line", "End" }, + { "f4_home_first_non_whitespace", "Home" }, + { "page_up", "PageUp" }, + { "page_down", "PageDown" }, + { "goto_beginning_of_file", "PageUp", "Control" }, + { "goto_end_of_file", "PageDown", "Control" }, + + // NOTE(rjf): Mark + { "set_mark", "Space", "Control" }, + { "cursor_mark_swap", "M", "Control" }, + + // NOTE(rjf): Search + { "f4_search", "F", "Control" }, + { "f4_reverse_search", "R", "Control" }, + { "list_all_locations", "F", "Control", "Shift" }, + { "list_all_substring_locations_case_insensitive", "F", "Alt" }, + { "goto_line", "G", "Control" }, + { "list_all_locations_of_selection", "G", "Control", "Shift" }, + { "search_identifier", "T", "Control" }, + { "list_all_locations_of_identifier", "T", "Control", "Shift" }, + + // NOTE(rjf): Replace + { "replace_in_range", "A", "Control" }, + { "query_replace", "Q", "Control" }, + { "query_replace_identifier", "Q", "Control", "Shift" }, + { "query_replace_selection", "Q", "Alt" }, + + // NOTE(rjf): Clipboard + { "copy", "C", "Control" }, + { "paste_and_indent", "V", "Control" }, + { "paste_next_and_indent", "V", "Control", "Shift" }, + { "cut", "X", "Control" }, + + // NOTE(rjf): Lego + { "f4_lego_buffer_place", "F1", }, + { "f4_lego_buffer_place", "F2", }, + { "f4_lego_buffer_place", "F3", }, + { "f4_lego_buffer_place", "F4", }, + + // NOTE(rjf): Deletion + { "delete_range", "D", "Control" }, + { "delete_line", "D", "Control", "Shift" }, + + // NOTE(rjf): Insertion + { "duplicate_line", "L", "Control" }, + + // NOTE(rjf): View + { "center_view", "E", "Control" }, + { "left_adjust_view", "E", "Control", "Shift" }, + + // NOTE(rjf): File + { "kill_buffer", "K", "Control", "Shift" }, + { "reopen", "O", "Alt", "Shift" }, + { "save", "S", "Control" }, + { "save_all_dirty_buffers", "S", "Control", "Shift" }, + { "redo", "Y", "Control" }, + { "undo", "Z", "Control" }, + { "view_buffer_other_panel", "1", "Control" }, + + // NOTE(rjf): Meta + { "swap_panels", "2", "Control" }, + { "if_read_only_goto_position", "Return" }, + { "if_read_only_goto_position_same_panel", "Return", "Shift" }, + { "view_jump_list_with_lister", "Period", "Control", "Shift" }, + + // NOTE(rjf): Code Peek + { "f4_code_peek", "Tick", "Alt" }, + { "f4_code_peek_yank", "Tab", "Control" }, + { "f4_code_peek_clear", "Shift", "Alt" }, + + // NOTE(rjf): Go To Def + { "f4_go_to_definition", "Return", "Control" }, + { "f4_go_to_definition_same_panel", "Return", "Control", "Shift" }, + + // NOTE(rjf): Helpers + { "f4_write_zero_struct", "0", "Control" }, + { "f4_toggle_enclosure_side", "Semicolon", "Alt" }, +}; + +keys_code = +{ + { "f4_comment_selection", "Semicolon", "Control" }, + { "f4_uncomment_selection", "Semicolon", "Control", "Shift", }, + { "f4_autocomplete_or_indent", "Tab" }, + { "f4_unindent", "Tab", "Shift" }, + { "word_complete_drop_down", "Tab", "Shift", "Control" }, + { "write_block", "R", "Alt" }, + { "write_todo", "T", "Alt" }, + { "write_note", "Y", "Alt" }, + { "list_all_locations_of_type_definition", "D", "Alt" }, + { "list_all_locations_of_type_definition_of_identifier", "T", "Alt", "Shift" }, + { "open_long_braces", "LeftBracket", "Control" }, + { "open_long_braces_semicolon", "LeftBracket", "Control", "Shift" }, + { "open_long_braces_break", "RightBracket", "Control", "Shift" }, + { "select_surrounding_scope", "LeftBracket", "Alt" }, + { "select_surrounding_scope_maximal", "LeftBracket", "Alt", "Shift" }, + { "select_prev_scope_absolute", "RightBracket", "Alt" }, + { "select_prev_top_most_scope", "RightBracket", "Alt", "Shift" }, + { "select_next_scope_absolute", "Quote", "Alt" }, + { "select_next_scope_after_current", "Quote", "Alt", "Shift" }, + { "place_in_scope", "ForwardSlash", "Alt" }, + { "delete_current_scope", "Minus", "Alt" }, + { "if0_off", "I", "Alt" }, + { "open_file_in_quotes", "1", "Alt" }, + { "open_matching_file_cpp", "2", "Alt" }, + + { "f4_lego_store_range", "F5", "Alt" }, + { "f4_lego_store_range", "F6", "Alt" }, + { "f4_lego_store_range", "F7", "Alt" }, + { "f4_lego_store_range", "F8", "Alt" }, + + { "f4_lego_store_token", "F5" }, + { "f4_lego_store_token", "F6" }, + { "f4_lego_store_token", "F7" }, + { "f4_lego_store_token", "F8" }, + +}; \ No newline at end of file diff --git a/dist_files/4coder_fleury/config.4coder b/dist_files/4coder_fleury/config.4coder new file mode 100644 index 0000000..be2ffb9 --- /dev/null +++ b/dist_files/4coder_fleury/config.4coder @@ -0,0 +1,99 @@ +// Command Mapping +// "" - Leave the bindings unaltered - use this when writing your own customization! +// "choose" - Ask 4coder to choose based on platform. +// "default" - Use the default keybindings 4coder has always had. +// "mac-default" - Use keybindings similar to those found in other Mac applications. +mapping = ""; + +// MODE +// "4coder" - The default 4coder mode that has been around since the beginning of time (2015) +// "notepad-like" - Single "thin" cursor and highlight ranges like in notepad, sublime, notepad++, etc +mode = "4coder"; +bind_by_physical_key = false; + +// UI +use_scroll_bars = false; +use_file_bars = true; +use_error_highlight = true; +use_jump_highlight = true; +use_scope_highlight = true; +use_paren_helper = true; +use_comment_keywords = true; +lister_whole_word_backspace_when_modified = false; +show_line_number_margins = false; +enable_output_wrapping = false; + +enable_undo_fade_out = false; + +// cursor_roundess is a value [0,50] setting the radius of +// the cursor and mark's roundness as a percentage of their width +// (At 50 the left and right corners will be so round they form a semi-circle, +// hence 50 is the max) +cursor_roundness = 10; + +// mark_thickness is a pixel count value setting the +// thickness of the mark wire box in original mode +mark_thickness = 2; + +// lister_roundess is a value [0,50] setting the radius of +// the lister items' roundness as a percentage of their height +lister_roundness = 20; + +// Code Wrapping +treat_as_code = ".cpp.c.hpp.h.cc.cs.java.rs.glsl.m.mm.ds.md.4coder.jai.vert.frag"; +enable_virtual_whitespace = true; +virtual_whitespace_regular_indent = 1; +enable_code_wrapping = true; + +// This only applies to code files in code-wrapping mode. +// Plain text and code files without virtual-whitespace will not be effected. +automatically_indent_text_on_save = true; + +// When set to true, all unsaved changes will be saved on a build. +automatically_save_changes_on_build = true; + +// Load project on startup +automatically_load_project = true; + +// Indentation +indent_with_tabs = false; +indent_width = 4; +default_tab_width = 4; + +// Theme +default_theme_name = "theme-fleury"; +highlight_line_at_cursor = true; + +// Font +default_font_name = "liberation-mono.ttf"; +default_font_size = 14; +default_font_hinting = true; + +// aa modes: +// 8bit - mono-chrome 0-255 opacity channel per pixel +// 1bit - mono-chrome 0/1 opacity channel per pixel +default_font_aa_mode = "8bit"; + +// User +user_name = "rjf"; + +// Keyboard AltGr setting +lalt_lctrl_is_altgr = false; + +// Project setup configuration +default_compiler_bat = "cl"; +default_flags_bat = "-FC -GR- -EHa- -nologo -Zi"; +default_compiler_sh = "g++"; +default_flags_sh = "-g"; + +// NOTE(rjf): Fleury 4coder Disabling Options +// f4_disable_brace_highlight = true; +// f4_disable_close_brace_annotation = true; +// f4_disable_brace_lines = true; +// f4_disable_progress_bar = true; +// f4_disable_divider_comments = true; +// f4_disable_error_annotations = true; +// f4_disable_calc_comments = true; +// f4_poscontext_draw_at_bottom_of_buffer = true; +// f4_disable_poscontext = true; +// f4_disable_cursor_token_occurance = true; diff --git a/dist_files/4coder_fleury/custom_4coder.dll b/dist_files/4coder_fleury/custom_4coder.dll new file mode 100644 index 0000000..301a4cc Binary files /dev/null and b/dist_files/4coder_fleury/custom_4coder.dll differ diff --git a/dist_files/4coder_fleury/custom_4coder.pdb b/dist_files/4coder_fleury/custom_4coder.pdb new file mode 100644 index 0000000..5911dd4 Binary files /dev/null and b/dist_files/4coder_fleury/custom_4coder.pdb differ diff --git a/dist_files/4coder_fleury/custom_4coder.so b/dist_files/4coder_fleury/custom_4coder.so new file mode 100644 index 0000000..60c5c2f Binary files /dev/null and b/dist_files/4coder_fleury/custom_4coder.so differ diff --git a/dist_files/4coder_fleury/theme-fleury.4coder b/dist_files/4coder_fleury/theme-fleury.4coder new file mode 100644 index 0000000..5ce6409 --- /dev/null +++ b/dist_files/4coder_fleury/theme-fleury.4coder @@ -0,0 +1,64 @@ +defcolor_bar = 0xFF000000; +defcolor_base = 0xFFfcaa05; +defcolor_pop1 = 0xffde8150; +defcolor_pop2 = 0xFFFF0000; +defcolor_back = 0xFF020202; +defcolor_margin = 0xFF222425; +defcolor_margin_hover = 0xff63523d; +defcolor_margin_active = 0xff63523d; +defcolor_list_item = { 0xFF222425, defcolor_back}; +defcolor_list_item_hover = { 0xff362e25, defcolor_margin}; +defcolor_list_item_active = { 0xff63523d, defcolor_margin}; +defcolor_cursor = { 0xFF00EE00, 0xffe0741b, 0xff1be094, 0xffba60c4 }; +defcolor_at_cursor = 0xFF0C0C0C; +defcolor_highlight_cursor_line = 0xFF1E1E1E; +defcolor_highlight = 0xFF303040; +defcolor_at_highlight = 0xFFFF44DD; +defcolor_mark = 0xFF494949; +defcolor_text_default = 0xffb99468; +defcolor_comment = 0xff666666; +defcolor_comment_pop = { 0xff2ab34f, 0xFFdb2828 }; +defcolor_keyword = 0xfff0c674; +defcolor_str_constant = 0xffffa900; +defcolor_char_constant = 0xffffa900; +defcolor_int_constant = 0xffffa900; +defcolor_float_constant = 0xffffa900; +defcolor_bool_constant = 0xffffa900; +defcolor_preproc = 0xFFdc7575; +defcolor_include = 0xffffa900; +defcolor_special_character = 0xFFFF0000; +defcolor_ghost_character = 0xFF4E5E46; +defcolor_highlight_junk = 0xFF3A0000; +defcolor_highlight_white = 0xFF003A3A; +defcolor_paste = 0xFFDDEE00; +defcolor_undo = 0xFF00DDEE; +defcolor_back_cycle = { 0xFF020202, 0xFF020202, 0xFF020202, 0xFF020202, 0xFF020202, 0xFF020202, 0xFF020202, 0xFF100202, 0xFF300202, 0xFF500202, 0xFF700202}; +defcolor_text_cycle = { 0xFFA00000, 0xFF00A000, 0xFF0030B0, 0xFFA0A000 }; +defcolor_line_numbers_back = 0xFF101010; +defcolor_line_numbers_text = 0xFF404040; + +fleury_color_syntax_crap = 0xff5c4d3c; +fleury_color_operators = 0xFFbd2d2d; +fleury_color_inactive_pane_overlay = 0x44000000; +fleury_color_inactive_pane_background = 0xff000000; +fleury_color_file_progress_bar = 0x60634323; +fleury_color_brace_highlight = { 0xff8ffff2 }; +fleury_color_brace_line = { 0x809ba290 }; +fleury_color_brace_annotation = { 0x809ba290 }; +fleury_color_index_product_type = 0xFFedb211; +fleury_color_index_sum_type = 0xFFa7eb13; +fleury_color_index_function = 0xFFde451f; +fleury_color_index_macro = 0xFF2895c7; +fleury_color_index_constant = 0xff6eb535; +fleury_color_index_comment_tag = 0xffffae00; +fleury_color_index_decl = 0xffc9598a; +fleury_color_cursor_macro = 0xffde2368; +fleury_color_cursor_power_mode = 0xffefaf2f; +fleury_color_cursor_inactive = 0xFF880000; +fleury_color_plot_cycle = { 0xff03d3fc, 0xff22b80b, 0xfff0bb0c, 0xfff0500c }; +fleury_color_token_highlight = 0x88f2d357; +fleury_color_token_minor_highlight = 0x44d19045; +fleury_color_error_annotation = 0xffff0000; +fleury_color_lego_grab = 0xffefaf6f; +fleury_color_lego_splat = 0xffefaaef; +fleury_color_comment_user_name = 0xffffdd23; diff --git a/dist_files/audio_test/chtulthu.wav b/dist_files/audio_test/chtulthu.wav new file mode 100644 index 0000000..5eee56e Binary files /dev/null and b/dist_files/audio_test/chtulthu.wav differ diff --git a/dist_files/audio_test/hit.wav b/dist_files/audio_test/hit.wav new file mode 100644 index 0000000..370d270 Binary files /dev/null and b/dist_files/audio_test/hit.wav differ diff --git a/dist_files/audio_test/raygun_zap.wav b/dist_files/audio_test/raygun_zap.wav new file mode 100644 index 0000000..38a959c Binary files /dev/null and b/dist_files/audio_test/raygun_zap.wav differ diff --git a/dist_files/fonts/Inconsolata-Regular.ttf b/dist_files/fonts/Inconsolata-Regular.ttf new file mode 100644 index 0000000..a87ffba Binary files /dev/null and b/dist_files/fonts/Inconsolata-Regular.ttf differ diff --git a/dist_files/fonts/liberation-mono.ttf b/dist_files/fonts/liberation-mono.ttf new file mode 100644 index 0000000..61af64e Binary files /dev/null and b/dist_files/fonts/liberation-mono.ttf differ diff --git a/foreign/freetype2/freetype/config/ftconfig.h b/foreign/freetype2/freetype/config/ftconfig.h new file mode 100644 index 0000000..157a704 --- /dev/null +++ b/foreign/freetype2/freetype/config/ftconfig.h @@ -0,0 +1,473 @@ +/***************************************************************************/ +/* */ +/* ftconfig.h */ +/* */ +/* ANSI-specific configuration file (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This header file contains a number of macro definitions that are used */ + /* by the rest of the engine. Most of the macros here are automatically */ + /* determined at compile time, and you should not need to change it to */ + /* port FreeType, except to compile the library with a non-ANSI */ + /* compiler. */ + /* */ + /* Note however that if some specific modifications are needed, we */ + /* advise you to place a modified copy in your build directory. */ + /* */ + /* The build directory is usually `builds/', and contains */ + /* system-specific files that are always included first when building */ + /* the library. */ + /* */ + /* This ANSI version should stay in `include/config/'. */ + /* */ + /*************************************************************************/ + +#ifndef FTCONFIG_H_ +#define FTCONFIG_H_ + +#include +#include FT_CONFIG_OPTIONS_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ + /* */ + /* These macros can be toggled to suit a specific system. The current */ + /* ones are defaults used to compile FreeType in an ANSI C environment */ + /* (16bit compilers are also supported). Copy this file to your own */ + /* `builds/' directory, and edit it to port the engine. */ + /* */ + /*************************************************************************/ + + + /* There are systems (like the Texas Instruments 'C54x) where a `char' */ + /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ + /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ + /* `char' type. */ + +#ifndef FT_CHAR_BIT +#define FT_CHAR_BIT CHAR_BIT +#endif + + + /* The size of an `int' type. */ +#if FT_UINT_MAX == 0xFFFFUL +#define FT_SIZEOF_INT (16 / FT_CHAR_BIT) +#elif FT_UINT_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_INT (32 / FT_CHAR_BIT) +#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_INT (64 / FT_CHAR_BIT) +#else +#error "Unsupported size of `int' type!" +#endif + + /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ + /* DM642) is recognized but avoided. */ +#if FT_ULONG_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL +#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT) +#else +#error "Unsupported size of `long' type!" +#endif + + + /* FT_UNUSED is a macro used to indicate that a given parameter is not */ + /* used -- this is only used to get rid of unpleasant compiler warnings */ +#ifndef FT_UNUSED +#define FT_UNUSED( arg ) ( (arg) = (arg) ) +#endif + + + /*************************************************************************/ + /* */ + /* AUTOMATIC CONFIGURATION MACROS */ + /* */ + /* These macros are computed from the ones defined above. Don't touch */ + /* their definition, unless you know precisely what you are doing. No */ + /* porter should need to mess with them. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Mac support */ + /* */ + /* This is the only necessary change, so it is defined here instead */ + /* providing a new configuration file. */ + /* */ +#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) + /* no Carbon frameworks for 64bit 10.4.x */ + /* AvailabilityMacros.h is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion */ +#include +#ifdef ECANCELED /* defined since 10.2 */ +#include "AvailabilityMacros.h" +#endif +#if defined( __LP64__ ) && \ + ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) +#undef FT_MACINTOSH +#endif + +#elif defined( __SC__ ) || defined( __MRC__ ) + /* Classic MacOS compilers */ +#include "ConditionalMacros.h" +#if TARGET_OS_MAC +#define FT_MACINTOSH 1 +#endif + +#endif + + + /*************************************************************************/ + /* */ + /*
*/ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int16 */ + /* */ + /* */ + /* A typedef for a 16bit signed integer type. */ + /* */ + typedef signed short FT_Int16; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt16 */ + /* */ + /* */ + /* A typedef for a 16bit unsigned integer type. */ + /* */ + typedef unsigned short FT_UInt16; + + /* */ + + + /* this #if 0 ... #endif clause is for documentation purposes */ +#if 0 + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int32 */ + /* */ + /* */ + /* A typedef for a 32bit signed integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef signed XXX FT_Int32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt32 */ + /* */ + /* A typedef for a 32bit unsigned integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef unsigned XXX FT_UInt32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int64 */ + /* */ + /* A typedef for a 64bit signed integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef signed XXX FT_Int64; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt64 */ + /* */ + /* A typedef for a 64bit unsigned integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef unsigned XXX FT_UInt64; + + /* */ + +#endif + +#if FT_SIZEOF_INT == (32 / FT_CHAR_BIT) + + typedef signed int FT_Int32; + typedef unsigned int FT_UInt32; + +#elif FT_SIZEOF_LONG == (32 / FT_CHAR_BIT) + + typedef signed long FT_Int32; + typedef unsigned long FT_UInt32; + +#else +#error "no 32bit type found -- please check your configuration files" +#endif + + + /* look up an integer type that is at least 32 bits */ +#if FT_SIZEOF_INT >= (32 / FT_CHAR_BIT) + + typedef int FT_Fast; + typedef unsigned int FT_UFast; + +#elif FT_SIZEOF_LONG >= (32 / FT_CHAR_BIT) + + typedef long FT_Fast; + typedef unsigned long FT_UFast; + +#endif + + + /* determine whether we have a 64-bit int type for platforms without */ + /* Autoconf */ +#if FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) + + /* FT_LONG64 must be defined if a 64-bit type is available */ +#define FT_LONG64 +#define FT_INT64 long +#define FT_UINT64 unsigned long + + /*************************************************************************/ + /* */ + /* A 64-bit data type may create compilation problems if you compile */ + /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ + /* types if __STDC__ is defined. You can however ignore this rule */ + /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ + /* */ +#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) + +#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L + +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __BORLANDC__ ) /* Borland C++ */ + + /* XXXX: We should probably check the value of __BORLANDC__ in order */ + /* to test the compiler version. */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __WATCOMC__ ) /* Watcom C++ */ + + /* Watcom doesn't provide 64-bit data types */ + +#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ + +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( __GNUC__ ) + + /* GCC provides the `long long' type */ +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#endif /* __STDC_VERSION__ >= 199901L */ + +#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ + +#ifdef FT_LONG64 + typedef FT_INT64 FT_Int64; + typedef FT_UINT64 FT_UInt64; +#endif + + + /*************************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /*************************************************************************/ + + +#define FT_BEGIN_STMNT do { +#define FT_END_STMNT } while ( 0 ) +#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT + + + /* typeof condition taken from gnulib's `intprops.h' header file */ +#if ( __GNUC__ >= 2 || \ + defined( __IBM__TYPEOF__ ) || \ + ( __SUNPRO_C >= 0x5110 && !__STDC__ ) ) +#define FT_TYPEOF( type ) (__typeof__ (type)) +#else +#define FT_TYPEOF( type ) /* empty */ +#endif + + +#ifdef FT_MAKE_OPTION_SINGLE_OBJECT + +#define FT_LOCAL( x ) static x +#define FT_LOCAL_DEF( x ) static x + +#else + +#ifdef __cplusplus +#define FT_LOCAL( x ) extern "C" x +#define FT_LOCAL_DEF( x ) extern "C" x +#else +#define FT_LOCAL( x ) extern x +#define FT_LOCAL_DEF( x ) x +#endif + +#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ + +#define FT_LOCAL_ARRAY( x ) extern const x +#define FT_LOCAL_ARRAY_DEF( x ) const x + + +#ifndef FT_BASE + +#ifdef __cplusplus +#define FT_BASE( x ) extern "C" x +#else +#define FT_BASE( x ) extern x +#endif + +#endif /* !FT_BASE */ + + +#ifndef FT_BASE_DEF + +#ifdef __cplusplus +#define FT_BASE_DEF( x ) x +#else +#define FT_BASE_DEF( x ) x +#endif + +#endif /* !FT_BASE_DEF */ + + +#ifndef FT_EXPORT + +#ifdef __cplusplus +#define FT_EXPORT( x ) extern "C" x +#else +#define FT_EXPORT( x ) extern x +#endif + +#endif /* !FT_EXPORT */ + + +#ifndef FT_EXPORT_DEF + +#ifdef __cplusplus +#define FT_EXPORT_DEF( x ) extern "C" x +#else +#define FT_EXPORT_DEF( x ) extern x +#endif + +#endif /* !FT_EXPORT_DEF */ + + +#ifndef FT_EXPORT_VAR + +#ifdef __cplusplus +#define FT_EXPORT_VAR( x ) extern "C" x +#else +#define FT_EXPORT_VAR( x ) extern x +#endif + +#endif /* !FT_EXPORT_VAR */ + + /* The following macros are needed to compile the library with a */ + /* C++ compiler and with 16bit compilers. */ + /* */ + + /* This is special. Within C++, you must specify `extern "C"' for */ + /* functions which are used via function pointers, and you also */ + /* must do that for structures which contain function pointers to */ + /* assure C linkage -- it's not possible to have (local) anonymous */ + /* functions which are accessed by (global) function pointers. */ + /* */ + /* */ + /* FT_CALLBACK_DEF is used to _define_ a callback function. */ + /* */ + /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ + /* contains pointers to callback functions. */ + /* */ + /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ + /* that contains pointers to callback functions. */ + /* */ + /* */ + /* Some 16bit compilers have to redefine these macros to insert */ + /* the infamous `_cdecl' or `__fastcall' declarations. */ + /* */ +#ifndef FT_CALLBACK_DEF +#ifdef __cplusplus +#define FT_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_CALLBACK_DEF( x ) static x +#endif +#endif /* FT_CALLBACK_DEF */ + +#ifndef FT_CALLBACK_TABLE +#ifdef __cplusplus +#define FT_CALLBACK_TABLE extern "C" +#define FT_CALLBACK_TABLE_DEF extern "C" +#else +#define FT_CALLBACK_TABLE extern +#define FT_CALLBACK_TABLE_DEF /* nothing */ +#endif +#endif /* FT_CALLBACK_TABLE */ + + +FT_END_HEADER + + +#endif /* FTCONFIG_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/config/ftheader.h b/foreign/freetype2/freetype/config/ftheader.h new file mode 100644 index 0000000..68e1483 --- /dev/null +++ b/foreign/freetype2/freetype/config/ftheader.h @@ -0,0 +1,833 @@ +/***************************************************************************/ +/* */ +/* ftheader.h */ +/* */ +/* Build macros of the FreeType 2 library. */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#ifndef FTHEADER_H_ +#define FTHEADER_H_ + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_BEGIN_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_END_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* C++ compiler. */ + /* */ +#ifdef __cplusplus +#define FT_BEGIN_HEADER extern "C" { +#else +#define FT_BEGIN_HEADER /* nothing */ +#endif + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_END_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_BEGIN_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* C++ compiler. */ + /* */ +#ifdef __cplusplus +#define FT_END_HEADER } +#else +#define FT_END_HEADER /* nothing */ +#endif + + + /*************************************************************************/ + /* */ + /* Aliases for the FreeType 2 public and configuration files. */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /*
*/ + /* header_file_macros */ + /* */ + /* */ + /* Header File Macros */ + /* */ + /* <Abstract> */ + /* Macro definitions used to #include specific header files. */ + /* */ + /* <Description> */ + /* The following macros are defined to the name of specific */ + /* FreeType~2 header files. They can be used directly in #include */ + /* statements as in: */ + /* */ + /* { */ + /* #include FT_FREETYPE_H */ + /* #include FT_MULTIPLE_MASTERS_H */ + /* #include FT_GLYPH_H */ + /* } */ + /* */ + /* There are several reasons why we are now using macros to name */ + /* public header files. The first one is that such macros are not */ + /* limited to the infamous 8.3~naming rule required by DOS (and */ + /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ + /* */ + /* The second reason is that it allows for more flexibility in the */ + /* way FreeType~2 is installed on a given system. */ + /* */ + /*************************************************************************/ + + + /* configuration files */ + + /************************************************************************* + * + * @macro: + * FT_CONFIG_CONFIG_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 configuration data. + * + */ +#ifndef FT_CONFIG_CONFIG_H +#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_STANDARD_LIBRARY_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 interface to the standard C library functions. + * + */ +#ifndef FT_CONFIG_STANDARD_LIBRARY_H +#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_OPTIONS_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 project-specific configuration options. + * + */ +#ifndef FT_CONFIG_OPTIONS_H +#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_MODULES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 modules that are statically linked to new library + * instances in @FT_Init_FreeType. + * + */ +#ifndef FT_CONFIG_MODULES_H +#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h> +#endif + + /* */ + + /* public headers */ + + /************************************************************************* + * + * @macro: + * FT_FREETYPE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * base FreeType~2 API. + * + */ +#define FT_FREETYPE_H <freetype/freetype.h> + + + /************************************************************************* + * + * @macro: + * FT_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 error codes (and messages). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_ERRORS_H <freetype/fterrors.h> + + + /************************************************************************* + * + * @macro: + * FT_MODULE_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 module error offsets (and messages). + * + */ +#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> + + + /************************************************************************* + * + * @macro: + * FT_SYSTEM_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 interface to low-level operations (i.e., memory management + * and stream i/o). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_SYSTEM_H <freetype/ftsystem.h> + + + /************************************************************************* + * + * @macro: + * FT_IMAGE_H + * + * @description: + * A macro used in #include statements to name the file containing type + * definitions related to glyph images (i.e., bitmaps, outlines, + * scan-converter parameters). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_IMAGE_H <freetype/ftimage.h> + + + /************************************************************************* + * + * @macro: + * FT_TYPES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * basic data types defined by FreeType~2. + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_TYPES_H <freetype/fttypes.h> + + + /************************************************************************* + * + * @macro: + * FT_LIST_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list management API of FreeType~2. + * + * (Most applications will never need to include this file.) + * + */ +#define FT_LIST_H <freetype/ftlist.h> + + + /************************************************************************* + * + * @macro: + * FT_OUTLINE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * scalable outline management API of FreeType~2. + * + */ +#define FT_OUTLINE_H <freetype/ftoutln.h> + + + /************************************************************************* + * + * @macro: + * FT_SIZES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API which manages multiple @FT_Size objects per face. + * + */ +#define FT_SIZES_H <freetype/ftsizes.h> + + + /************************************************************************* + * + * @macro: + * FT_MODULE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * module management API of FreeType~2. + * + */ +#define FT_MODULE_H <freetype/ftmodapi.h> + + + /************************************************************************* + * + * @macro: + * FT_RENDER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * renderer module management API of FreeType~2. + * + */ +#define FT_RENDER_H <freetype/ftrender.h> + + + /************************************************************************* + * + * @macro: + * FT_AUTOHINTER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the auto-hinting module. + * + */ +#define FT_AUTOHINTER_H <freetype/ftautoh.h> + + + /************************************************************************* + * + * @macro: + * FT_CFF_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the CFF driver module. + * + */ +#define FT_CFF_DRIVER_H <freetype/ftcffdrv.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the TrueType driver module. + * + */ +#define FT_TRUETYPE_DRIVER_H <freetype/ftttdrv.h> + + + /************************************************************************* + * + * @macro: + * FT_TYPE1_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the Type~1 format. + * + */ +#define FT_TYPE1_TABLES_H <freetype/t1tables.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_IDS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * enumeration values which identify name strings, languages, encodings, + * etc. This file really contains a _large_ set of constant macro + * definitions, taken from the TrueType and OpenType specifications. + * + */ +#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the TrueType (as well as OpenType) format. + * + */ +#define FT_TRUETYPE_TABLES_H <freetype/tttables.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TAGS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of TrueType four-byte `tags' which identify blocks in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_TRUETYPE_TAGS_H <freetype/tttags.h> + + + /************************************************************************* + * + * @macro: + * FT_BDF_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which accesses BDF-specific strings from a + * face. + * + */ +#define FT_BDF_H <freetype/ftbdf.h> + + + /************************************************************************* + * + * @macro: + * FT_CID_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which access CID font information from a + * face. + * + */ +#define FT_CID_H <freetype/ftcid.h> + + + /************************************************************************* + * + * @macro: + * FT_GZIP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports gzip-compressed files. + * + */ +#define FT_GZIP_H <freetype/ftgzip.h> + + + /************************************************************************* + * + * @macro: + * FT_LZW_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports LZW-compressed files. + * + */ +#define FT_LZW_H <freetype/ftlzw.h> + + + /************************************************************************* + * + * @macro: + * FT_BZIP2_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports bzip2-compressed files. + * + */ +#define FT_BZIP2_H <freetype/ftbzip2.h> + + + /************************************************************************* + * + * @macro: + * FT_WINFONTS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports Windows FNT files. + * + */ +#define FT_WINFONTS_H <freetype/ftwinfnt.h> + + + /************************************************************************* + * + * @macro: + * FT_GLYPH_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional glyph management component. + * + */ +#define FT_GLYPH_H <freetype/ftglyph.h> + + + /************************************************************************* + * + * @macro: + * FT_BITMAP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional bitmap conversion component. + * + */ +#define FT_BITMAP_H <freetype/ftbitmap.h> + + + /************************************************************************* + * + * @macro: + * FT_BBOX_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional exact bounding box computation routines. + * + */ +#define FT_BBOX_H <freetype/ftbbox.h> + + + /************************************************************************* + * + * @macro: + * FT_CACHE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional FreeType~2 cache sub-system. + * + */ +#define FT_CACHE_H <freetype/ftcache.h> + + + /************************************************************************* + * + * @macro: + * FT_CACHE_IMAGE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `glyph image' API of the FreeType~2 cache sub-system. + * + * It is used to define a cache for @FT_Glyph elements. You can also + * use the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need to + * store small glyph bitmaps, as it will use less memory. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * glyph image-related cache declarations. + * + */ +#define FT_CACHE_IMAGE_H FT_CACHE_H + + + /************************************************************************* + * + * @macro: + * FT_CACHE_SMALL_BITMAPS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `small bitmaps' API of the FreeType~2 cache sub-system. + * + * It is used to define a cache for small glyph bitmaps in a relatively + * memory-efficient way. You can also use the API defined in + * @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, + * including scalable outlines. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * small bitmaps-related cache declarations. + * + */ +#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H + + + /************************************************************************* + * + * @macro: + * FT_CACHE_CHARMAP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `charmap' API of the FreeType~2 cache sub-system. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * charmap-based cache declarations. + * + */ +#define FT_CACHE_CHARMAP_H FT_CACHE_H + + + /************************************************************************* + * + * @macro: + * FT_MAC_H + * + * @description: + * A macro used in #include statements to name the file containing the + * Macintosh-specific FreeType~2 API. The latter is used to access + * fonts embedded in resource forks. + * + * This header file must be explicitly included by client applications + * compiled on the Mac (note that the base API still works though). + * + */ +#define FT_MAC_H <freetype/ftmac.h> + + + /************************************************************************* + * + * @macro: + * FT_MULTIPLE_MASTERS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional multiple-masters management API of FreeType~2. + * + */ +#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> + + + /************************************************************************* + * + * @macro: + * FT_SFNT_NAMES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which accesses embedded `name' strings in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_SFNT_NAMES_H <freetype/ftsnames.h> + + + /************************************************************************* + * + * @macro: + * FT_OPENTYPE_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, + * GPOS, GSUB, JSTF). + * + */ +#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> + + + /************************************************************************* + * + * @macro: + * FT_GX_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, + * mort, morx, bsln, just, kern, opbd, trak, prop). + * + */ +#define FT_GX_VALIDATE_H <freetype/ftgxval.h> + + + /************************************************************************* + * + * @macro: + * FT_PFR_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which accesses PFR-specific data. + * + */ +#define FT_PFR_H <freetype/ftpfr.h> + + + /************************************************************************* + * + * @macro: + * FT_STROKER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which provides functions to stroke outline paths. + */ +#define FT_STROKER_H <freetype/ftstroke.h> + + + /************************************************************************* + * + * @macro: + * FT_SYNTHESIS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs artificial obliquing and emboldening. + */ +#define FT_SYNTHESIS_H <freetype/ftsynth.h> + + + /************************************************************************* + * + * @macro: + * FT_FONT_FORMATS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which provides functions specific to font formats. + */ +#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h> + + /* deprecated */ +#define FT_XFREE86_H FT_FONT_FORMATS_H + + + /************************************************************************* + * + * @macro: + * FT_TRIGONOMETRY_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs trigonometric computations (e.g., + * cosines and arc tangents). + */ +#define FT_TRIGONOMETRY_H <freetype/fttrigon.h> + + + /************************************************************************* + * + * @macro: + * FT_LCD_FILTER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs color filtering for subpixel rendering. + */ +#define FT_LCD_FILTER_H <freetype/ftlcdfil.h> + + + /************************************************************************* + * + * @macro: + * FT_UNPATENTED_HINTING_H + * + * @description: + * Deprecated. + */ +#define FT_UNPATENTED_HINTING_H <freetype/ttunpat.h> + + + /************************************************************************* + * + * @macro: + * FT_INCREMENTAL_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs incremental glyph loading. + */ +#define FT_INCREMENTAL_H <freetype/ftincrem.h> + + + /************************************************************************* + * + * @macro: + * FT_GASP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which returns entries from the TrueType GASP table. + */ +#define FT_GASP_H <freetype/ftgasp.h> + + + /************************************************************************* + * + * @macro: + * FT_ADVANCES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which returns individual and ranged glyph advances. + */ +#define FT_ADVANCES_H <freetype/ftadvanc.h> + + + /* */ + +#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h> + + + /* The internals of the cache sub-system are no longer exposed. We */ + /* default to FT_CACHE_H at the moment just in case, but we know of */ + /* no rogue client that uses them. */ + /* */ +#define FT_CACHE_MANAGER_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_MRU_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_MANAGER_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_CACHE_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_GLYPH_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_IMAGE_H <freetype/ftcache.h> +#define FT_CACHE_INTERNAL_SBITS_H <freetype/ftcache.h> + + +#define FT_INCREMENTAL_H <freetype/ftincrem.h> + +#define FT_TRUETYPE_UNPATENTED_H <freetype/ttunpat.h> + + + /* + * Include internal headers definitions from <internal/...> + * only when building the library. + */ +#ifdef FT2_BUILD_LIBRARY +#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> +#include FT_INTERNAL_INTERNAL_H +#endif /* FT2_BUILD_LIBRARY */ + + +#endif /* FTHEADER_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/config/ftmodule.h b/foreign/freetype2/freetype/config/ftmodule.h new file mode 100644 index 0000000..76d271a --- /dev/null +++ b/foreign/freetype2/freetype/config/ftmodule.h @@ -0,0 +1,32 @@ +/* + * This file registers the FreeType modules compiled into the library. + * + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `<topdir>/objs/') based on information + * from `<topdir>/modules.cfg'. + * + * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile + * FreeType without GNU make. + * + */ + +FT_USE_MODULE( FT_Module_Class, autofit_module_class ) +FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) +FT_USE_MODULE( FT_Module_Class, psaux_module_class ) +FT_USE_MODULE( FT_Module_Class, psnames_module_class ) +FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) +FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) +FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) + +/* EOF */ diff --git a/foreign/freetype2/freetype/config/ftoption.h b/foreign/freetype2/freetype/config/ftoption.h new file mode 100644 index 0000000..a8097fe --- /dev/null +++ b/foreign/freetype2/freetype/config/ftoption.h @@ -0,0 +1,851 @@ +/***************************************************************************/ +/* */ +/* ftoption.h */ +/* */ +/* User-selectable configuration macros (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTOPTION_H_ +#define FTOPTION_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* USER-SELECTABLE CONFIGURATION MACROS */ + /* */ + /* This file contains the default configuration macro definitions for */ + /* a standard build of the FreeType library. There are three ways to */ + /* use this file to build project-specific versions of the library: */ + /* */ + /* - You can modify this file by hand, but this is not recommended in */ + /* cases where you would like to build several versions of the */ + /* library from a single source directory. */ + /* */ + /* - You can put a copy of this file in your build directory, more */ + /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ + /* is the name of a directory that is included _before_ the FreeType */ + /* include path during compilation. */ + /* */ + /* The default FreeType Makefiles and Jamfiles use the build */ + /* directory `builds/<system>' by default, but you can easily change */ + /* that for your own projects. */ + /* */ + /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ + /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ + /* locate this file during the build. For example, */ + /* */ + /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ + /* #include <freetype/config/ftheader.h> */ + /* */ + /* will use `$BUILD/myftoptions.h' instead of this file for macro */ + /* definitions. */ + /* */ + /* Note also that you can similarly pre-define the macro */ + /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ + /* that are statically linked to the library at compile time. By */ + /* default, this file is <freetype/config/ftmodule.h>. */ + /* */ + /* We highly recommend using the third method whenever possible. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Uncomment the line below if you want to activate sub-pixel rendering */ + /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ + /* */ + /* Note that this feature is covered by several Microsoft patents */ + /* and should not be activated in any default build of the library. */ + /* */ + /* This macro has no impact on the FreeType API, only on its */ + /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ + /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ + /* the original size in case this macro isn't defined; however, each */ + /* triplet of subpixels has R=G=B. */ + /* */ + /* This is done to allow FreeType clients to run unmodified, forcing */ + /* them to display normal gray-level anti-aliased glyphs. */ + /* */ +/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + + /*************************************************************************/ + /* */ + /* Many compilers provide a non-ANSI 64-bit data type that can be used */ + /* by FreeType to speed up some computations. However, this will create */ + /* some problems when compiling the library in strict ANSI mode. */ + /* */ + /* For this reason, the use of 64-bit integers is normally disabled when */ + /* the __STDC__ macro is defined. You can however disable this by */ + /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ + /* */ + /* For most compilers, this will only create compilation warnings when */ + /* building the library. */ + /* */ + /* ObNote: The compiler-specific 64-bit integers are detected in the */ + /* file `ftconfig.h' either statically or through the */ + /* `configure' script on supported platforms. */ + /* */ +#undef FT_CONFIG_OPTION_FORCE_INT64 + + + /*************************************************************************/ + /* */ + /* If this macro is defined, do not try to use an assembler version of */ + /* performance-critical functions (e.g. FT_MulFix). You should only do */ + /* that to verify that the assembler function works properly, or to */ + /* execute benchmark tests of the various implementations. */ +/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ + + + /*************************************************************************/ + /* */ + /* If this macro is defined, try to use an inlined assembler version of */ + /* the `FT_MulFix' function, which is a `hotspot' when loading and */ + /* hinting glyphs, and which should be executed as fast as possible. */ + /* */ + /* Note that if your compiler or CPU is not supported, this will default */ + /* to the standard and portable implementation found in `ftcalc.c'. */ + /* */ +#define FT_CONFIG_OPTION_INLINE_MULFIX + + + /*************************************************************************/ + /* */ + /* LZW-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `compress' program. This is mostly used to parse many of the PCF */ + /* files that come with various X11 distributions. The implementation */ + /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ + /* (see src/lzw/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#define FT_CONFIG_OPTION_USE_LZW + + + /*************************************************************************/ + /* */ + /* Gzip-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `gzip' program. This is mostly used to parse many of the PCF files */ + /* that come with XFree86. The implementation uses `zlib' to */ + /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. See also */ + /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ + /* */ +#define FT_CONFIG_OPTION_USE_ZLIB + + + /*************************************************************************/ + /* */ + /* ZLib library selection */ + /* */ + /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ + /* It allows FreeType's `ftgzip' component to link to the system's */ + /* installation of the ZLib library. This is useful on systems like */ + /* Unix or VMS where it generally is already available. */ + /* */ + /* If you let it undefined, the component will use its own copy */ + /* of the zlib sources instead. These have been modified to be */ + /* included directly within the component and *not* export external */ + /* function names. This allows you to link any program with FreeType */ + /* _and_ ZLib without linking conflicts. */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ +/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ + + + /*************************************************************************/ + /* */ + /* Bzip2-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `bzip2' program. This is mostly used to parse many of the PCF */ + /* files that come with XFree86. The implementation uses `libbz2' to */ + /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ + /* Contrary to gzip, bzip2 currently is not included and need to use */ + /* the system available bzip2 implementation. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_BZIP2 */ + + + /*************************************************************************/ + /* */ + /* Define to disable the use of file stream functions and types, FILE, */ + /* fopen() etc. Enables the use of smaller system libraries on embedded */ + /* systems that have multiple system libraries, some with or without */ + /* file stream support, in the cases where file stream support is not */ + /* necessary such as memory loading of font files. */ + /* */ +/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ + + + /*************************************************************************/ + /* */ + /* PNG bitmap support. */ + /* */ + /* FreeType now handles loading color bitmap glyphs in the PNG format. */ + /* This requires help from the external libpng library. Uncompressed */ + /* color bitmaps do not need any external libraries and will be */ + /* supported regardless of this configuration. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_PNG */ + + + /*************************************************************************/ + /* */ + /* HarfBuzz support. */ + /* */ + /* FreeType uses the HarfBuzz library to improve auto-hinting of */ + /* OpenType fonts. If available, many glyphs not directly addressable */ + /* by a font's character map will be hinted also. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ + + + /*************************************************************************/ + /* */ + /* DLL export compilation */ + /* */ + /* When compiling FreeType as a DLL, some systems/compilers need a */ + /* special keyword in front OR after the return type of function */ + /* declarations. */ + /* */ + /* Two macros are used within the FreeType source code to define */ + /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ + /* */ + /* FT_EXPORT( return_type ) */ + /* */ + /* is used in a function declaration, as in */ + /* */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* */ + /* */ + /* FT_EXPORT_DEF( return_type ) */ + /* */ + /* is used in a function definition, as in */ + /* */ + /* FT_EXPORT_DEF( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* { */ + /* ... some code ... */ + /* return FT_Err_Ok; */ + /* } */ + /* */ + /* You can provide your own implementation of FT_EXPORT and */ + /* FT_EXPORT_DEF here if you want. If you leave them undefined, they */ + /* will be later automatically defined as `extern return_type' to */ + /* allow normal compilation. */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_EXPORT(x) extern x */ +/* #define FT_EXPORT_DEF(x) x */ + + + /*************************************************************************/ + /* */ + /* Glyph Postscript Names handling */ + /* */ + /* By default, FreeType 2 is compiled with the `psnames' module. This */ + /* module is in charge of converting a glyph name string into a */ + /* Unicode value, or return a Macintosh standard glyph name for the */ + /* use with the TrueType `post' table. */ + /* */ + /* Undefine this macro if you do not want `psnames' compiled in your */ + /* build of FreeType. This has the following effects: */ + /* */ + /* - The TrueType driver will provide its own set of glyph names, */ + /* if you build it to support postscript names in the TrueType */ + /* `post' table. */ + /* */ + /* - The Type 1 driver will not be able to synthesize a Unicode */ + /* charmap out of the glyphs found in the fonts. */ + /* */ + /* You would normally undefine this configuration macro when building */ + /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ + /* */ +#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Postscript Names to Unicode Values support */ + /* */ + /* By default, FreeType 2 is built with the `PSNames' module compiled */ + /* in. Among other things, the module is used to convert a glyph name */ + /* into a Unicode value. This is especially useful in order to */ + /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ + /* through a big table named the `Adobe Glyph List' (AGL). */ + /* */ + /* Undefine this macro if you do not want the Adobe Glyph List */ + /* compiled in your `PSNames' module. The Type 1 driver will not be */ + /* able to synthesize a Unicode charmap out of the glyphs found in the */ + /* fonts. */ + /* */ +#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST + + + /*************************************************************************/ + /* */ + /* Support for Mac fonts */ + /* */ + /* Define this macro if you want support for outline fonts in Mac */ + /* format (mac dfont, mac resource, macbinary containing a mac */ + /* resource) on non-Mac platforms. */ + /* */ + /* Note that the `FOND' resource isn't checked. */ + /* */ +#define FT_CONFIG_OPTION_MAC_FONTS + + + /*************************************************************************/ + /* */ + /* Guessing methods to access embedded resource forks */ + /* */ + /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ + /* GNU/Linux). */ + /* */ + /* Resource forks which include fonts data are stored sometimes in */ + /* locations which users or developers don't expected. In some cases, */ + /* resource forks start with some offset from the head of a file. In */ + /* other cases, the actual resource fork is stored in file different */ + /* from what the user specifies. If this option is activated, */ + /* FreeType tries to guess whether such offsets or different file */ + /* names must be used. */ + /* */ + /* Note that normal, direct access of resource forks is controlled via */ + /* the FT_CONFIG_OPTION_MAC_FONTS option. */ + /* */ +#ifdef FT_CONFIG_OPTION_MAC_FONTS +#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#endif + + + /*************************************************************************/ + /* */ + /* Allow the use of FT_Incremental_Interface to load typefaces that */ + /* contain no glyph data, but supply it via a callback function. */ + /* This is required by clients supporting document formats which */ + /* supply font data incrementally as the document is parsed, such */ + /* as the Ghostscript interpreter for the PostScript language. */ + /* */ +#define FT_CONFIG_OPTION_INCREMENTAL + + + /*************************************************************************/ + /* */ + /* The size in bytes of the render pool used by the scan-line converter */ + /* to do all of its work. */ + /* */ +#define FT_RENDER_POOL_SIZE 16384L + + + /*************************************************************************/ + /* */ + /* FT_MAX_MODULES */ + /* */ + /* The maximum number of modules that can be registered in a single */ + /* FreeType library object. 32 is the default. */ + /* */ +#define FT_MAX_MODULES 32 + + + /*************************************************************************/ + /* */ + /* Debug level */ + /* */ + /* FreeType can be compiled in debug or trace mode. In debug mode, */ + /* errors are reported through the `ftdebug' component. In trace */ + /* mode, additional messages are sent to the standard output during */ + /* execution. */ + /* */ + /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ + /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ + /* */ + /* Don't define any of these macros to compile in `release' mode! */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_LEVEL_ERROR */ +/* #define FT_DEBUG_LEVEL_TRACE */ + + + /*************************************************************************/ + /* */ + /* Autofitter debugging */ + /* */ + /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ + /* control the autofitter behaviour for debugging purposes with global */ + /* boolean variables (consequently, you should *never* enable this */ + /* while compiling in `release' mode): */ + /* */ + /* _af_debug_disable_horz_hints */ + /* _af_debug_disable_vert_hints */ + /* _af_debug_disable_blue_hints */ + /* */ + /* Additionally, the following functions provide dumps of various */ + /* internal autofit structures to stdout (using `printf'): */ + /* */ + /* af_glyph_hints_dump_points */ + /* af_glyph_hints_dump_segments */ + /* af_glyph_hints_dump_edges */ + /* af_glyph_hints_get_num_segments */ + /* af_glyph_hints_get_segment_offset */ + /* */ + /* As an argument, they use another global variable: */ + /* */ + /* _af_debug_hints */ + /* */ + /* Please have a look at the `ftgrid' demo program to see how those */ + /* variables and macros should be used. */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_AUTOFIT */ + + + /*************************************************************************/ + /* */ + /* Memory Debugging */ + /* */ + /* FreeType now comes with an integrated memory debugger that is */ + /* capable of detecting simple errors like memory leaks or double */ + /* deletes. To compile it within your build of the library, you */ + /* should define FT_DEBUG_MEMORY here. */ + /* */ + /* Note that the memory debugger is only activated at runtime when */ + /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ +/* #define FT_DEBUG_MEMORY */ + + + /*************************************************************************/ + /* */ + /* Module errors */ + /* */ + /* If this macro is set (which is _not_ the default), the higher byte */ + /* of an error code gives the module in which the error has occurred, */ + /* while the lower byte is the real error code. */ + /* */ + /* Setting this macro makes sense for debugging purposes only, since */ + /* it would break source compatibility of certain programs that use */ + /* FreeType 2. */ + /* */ + /* More details can be found in the files ftmoderr.h and fterrors.h. */ + /* */ +#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS + + + /*************************************************************************/ + /* */ + /* Position Independent Code */ + /* */ + /* If this macro is set (which is _not_ the default), FreeType2 will */ + /* avoid creating constants that require address fixups. Instead the */ + /* constants will be moved into a struct and additional intialization */ + /* code will be used. */ + /* */ + /* Setting this macro is needed for systems that prohibit address */ + /* fixups, such as BREW. */ + /* */ +/* #define FT_CONFIG_OPTION_PIC */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ + /* embedded bitmaps in all formats using the SFNT module (namely */ + /* TrueType & OpenType). */ + /* */ +#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ + /* load and enumerate the glyph Postscript names in a TrueType or */ + /* OpenType file. */ + /* */ + /* Note that when you do not compile the `PSNames' module by undefining */ + /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ + /* contain additional code used to read the PS Names table from a font. */ + /* */ + /* (By default, the module uses `PSNames' to extract glyph names.) */ + /* */ +#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ + /* access the internal name table in a SFNT-based format like TrueType */ + /* or OpenType. The name table contains various strings used to */ + /* describe the font, like family name, copyright, version, etc. It */ + /* does not contain any glyph name though. */ + /* */ + /* Accessing SFNT names is done through the functions declared in */ + /* `ftsnames.h'. */ + /* */ +#define TT_CONFIG_OPTION_SFNT_NAMES + + + /*************************************************************************/ + /* */ + /* TrueType CMap support */ + /* */ + /* Here you can fine-tune which TrueType CMap table format shall be */ + /* supported. */ +#define TT_CONFIG_CMAP_FORMAT_0 +#define TT_CONFIG_CMAP_FORMAT_2 +#define TT_CONFIG_CMAP_FORMAT_4 +#define TT_CONFIG_CMAP_FORMAT_6 +#define TT_CONFIG_CMAP_FORMAT_8 +#define TT_CONFIG_CMAP_FORMAT_10 +#define TT_CONFIG_CMAP_FORMAT_12 +#define TT_CONFIG_CMAP_FORMAT_13 +#define TT_CONFIG_CMAP_FORMAT_14 + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ + /* a bytecode interpreter in the TrueType driver. */ + /* */ + /* By undefining this, you will only compile the code necessary to load */ + /* TrueType glyphs without hinting. */ + /* */ + /* Do not #undef this macro here, since the build system might */ + /* define it for certain configurations only. */ + /* */ +#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ + /* EXPERIMENTAL subpixel hinting support into the TrueType driver. This */ + /* replaces the native TrueType hinting mechanism when anything but */ + /* FT_RENDER_MODE_MONO is requested. */ + /* */ + /* Enabling this causes the TrueType driver to ignore instructions under */ + /* certain conditions. This is done in accordance with the guide here, */ + /* with some minor differences: */ + /* */ + /* http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ + /* */ + /* By undefining this, you only compile the code necessary to hint */ + /* TrueType glyphs with native TT hinting. */ + /* */ + /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ + /* defined. */ + /* */ +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ + /* TrueType glyph loader to use Apple's definition of how to handle */ + /* component offsets in composite glyphs. */ + /* */ + /* Apple and MS disagree on the default behavior of component offsets */ + /* in composites. Apple says that they should be scaled by the scaling */ + /* factors in the transformation matrix (roughly, it's more complex) */ + /* while MS says they should not. OpenType defines two bits in the */ + /* composite flags array which can be used to disambiguate, but old */ + /* fonts will not have them. */ + /* */ + /* http://www.microsoft.com/typography/otspec/glyf.htm */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ + /* */ +#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ + /* support for Apple's distortable font technology (fvar, gvar, cvar, */ + /* and avar tables). This has many similarities to Type 1 Multiple */ + /* Masters support. */ + /* */ +#define TT_CONFIG_OPTION_GX_VAR_SUPPORT + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ + /* an embedded `BDF ' table within SFNT-based bitmap formats. */ + /* */ +#define TT_CONFIG_OPTION_BDF + + + /*************************************************************************/ + /* */ + /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */ + /* number of bytecode instructions executed for a single run of the */ + /* bytecode interpreter, needed to prevent infinite loops. You don't */ + /* want to change this except for very special situations (e.g., making */ + /* a library fuzzer spend less time to handle broken fonts). */ + /* */ + /* It is not expected that this value is ever modified by a configuring */ + /* script; instead, it gets surrounded with #ifndef ... #endif so that */ + /* the value can be set as a preprocessor option on the compiler's */ + /* command line. */ + /* */ +#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES +#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L +#endif + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ + /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ + /* required. */ + /* */ +#define T1_MAX_DICT_DEPTH 5 + + + /*************************************************************************/ + /* */ + /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ + /* calls during glyph loading. */ + /* */ +#define T1_MAX_SUBRS_CALLS 16 + + + /*************************************************************************/ + /* */ + /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ + /* minimum of 16 is required. */ + /* */ + /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ + /* */ +#define T1_MAX_CHARSTRINGS_OPERANDS 256 + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ + /* files into an existing face. Note that if set, the T1 driver will be */ + /* unable to produce kerning distances. */ + /* */ +#undef T1_CONFIG_OPTION_NO_AFM + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of the Multiple Masters font support in the Type 1 */ + /* driver. */ + /* */ +#undef T1_CONFIG_OPTION_NO_MM_SUPPORT + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** C F F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ + /* possible to set up the default values of the four control points that */ + /* define the stem darkening behaviour of the (new) CFF engine. For */ + /* more details please read the documentation of the */ + /* `darkening-parameters' property of the cff driver module (file */ + /* `ftcffdrv.h'), which allows the control at run-time. */ + /* */ + /* Do *not* undefine these macros! */ + /* */ +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 + + + /*************************************************************************/ + /* */ + /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the cff driver module. */ + /* */ +/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ + /* support. */ + /* */ +#define AF_CONFIG_OPTION_CJK + + /*************************************************************************/ + /* */ + /* Compile autofit module with Indic script support. */ + /* */ +#define AF_CONFIG_OPTION_INDIC + + /*************************************************************************/ + /* */ + /* Compile autofit module with warp hinting. The idea of the warping */ + /* code is to slightly scale and shift a glyph within a single dimension */ + /* so that as much of its segments are aligned (more or less) on the */ + /* grid. To find out the optimal scaling and shifting value, various */ + /* parameter combinations are tried and scored. */ + /* */ + /* This experimental option is active only if the rendering mode is */ + /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ + /* `warping' property of the auto-hinter (see file `ftautoh.h' for more */ + /* information; by default it is switched off). */ + /* */ +#define AF_CONFIG_OPTION_USE_WARPER + + /* */ + + + /* + * This macro is obsolete. Support has been removed in FreeType + * version 2.5. + */ +/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ + + + /* + * This macro is defined if native TrueType hinting is requested by the + * definitions above. + */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#define TT_USE_BYTECODE_INTERPRETER +#endif + + + /* + * Check CFF darkening parameters. The checks are the same as in function + * `cff_property_set' in file `cffdrivr.c'. + */ +#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500 +#error "Invalid CFF darkening parameters!" +#endif + +FT_END_HEADER + + +#endif /* FTOPTION_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/config/ftstdlib.h b/foreign/freetype2/freetype/config/ftstdlib.h new file mode 100644 index 0000000..9daea56 --- /dev/null +++ b/foreign/freetype2/freetype/config/ftstdlib.h @@ -0,0 +1,173 @@ +/***************************************************************************/ +/* */ +/* ftstdlib.h */ +/* */ +/* ANSI-specific library and header configuration file (specification */ +/* only). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file is used to group all #includes to the ANSI C library that */ + /* FreeType normally requires. It also defines macros to rename the */ + /* standard functions within the FreeType source code. */ + /* */ + /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ + /* */ + /*************************************************************************/ + + +#ifndef FTSTDLIB_H_ +#define FTSTDLIB_H_ + + +#include <stddef.h> + +#define ft_ptrdiff_t ptrdiff_t + + + /**********************************************************************/ + /* */ + /* integer limits */ + /* */ + /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ + /* of `int' and `long' in bytes at compile-time. So far, this works */ + /* for all platforms the library has been tested on. */ + /* */ + /* Note that on the extremely rare platforms that do not provide */ + /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ + /* old Crays where `int' is 36 bits), we do not make any guarantee */ + /* about the correct behaviour of FT2 with all fonts. */ + /* */ + /* In these case, `ftconfig.h' will refuse to compile anyway with a */ + /* message like `couldn't find 32-bit type' or something similar. */ + /* */ + /**********************************************************************/ + + +#include <limits.h> + +#define FT_CHAR_BIT CHAR_BIT +#define FT_USHORT_MAX USHRT_MAX +#define FT_INT_MAX INT_MAX +#define FT_INT_MIN INT_MIN +#define FT_UINT_MAX UINT_MAX +#define FT_LONG_MAX LONG_MAX +#define FT_ULONG_MAX ULONG_MAX + + + /**********************************************************************/ + /* */ + /* character and string processing */ + /* */ + /**********************************************************************/ + + +#include <string.h> + +#define ft_memchr memchr +#define ft_memcmp memcmp +#define ft_memcpy memcpy +#define ft_memmove memmove +#define ft_memset memset +#define ft_strcat strcat +#define ft_strcmp strcmp +#define ft_strcpy strcpy +#define ft_strlen strlen +#define ft_strncmp strncmp +#define ft_strncpy strncpy +#define ft_strrchr strrchr +#define ft_strstr strstr + + + /**********************************************************************/ + /* */ + /* file handling */ + /* */ + /**********************************************************************/ + + +#include <stdio.h> + +#define FT_FILE FILE +#define ft_fclose fclose +#define ft_fopen fopen +#define ft_fread fread +#define ft_fseek fseek +#define ft_ftell ftell +#define ft_sprintf sprintf + + + /**********************************************************************/ + /* */ + /* sorting */ + /* */ + /**********************************************************************/ + + +#include <stdlib.h> + +#define ft_qsort qsort + + + /**********************************************************************/ + /* */ + /* memory allocation */ + /* */ + /**********************************************************************/ + + +#define ft_scalloc calloc +#define ft_sfree free +#define ft_smalloc malloc +#define ft_srealloc realloc + + + /**********************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /**********************************************************************/ + + +#define ft_atol atol + + + /**********************************************************************/ + /* */ + /* execution control */ + /* */ + /**********************************************************************/ + + +#include <setjmp.h> + +#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ + /* jmp_buf is defined as a macro */ + /* on certain platforms */ + +#define ft_longjmp longjmp +#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ + + + /* the following is only used for debugging purposes, i.e., if */ + /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ + +#include <stdarg.h> + + +#endif /* FTSTDLIB_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/freetype.h b/foreign/freetype2/freetype/freetype.h new file mode 100644 index 0000000..4666d48 --- /dev/null +++ b/foreign/freetype2/freetype/freetype.h @@ -0,0 +1,4272 @@ +/***************************************************************************/ +/* */ +/* freetype.h */ +/* */ +/* FreeType high-level API and common types (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FREETYPE_H_ +#define FREETYPE_H_ + + +#ifndef FT_FREETYPE_H +#error "`ft2build.h' hasn't been included yet!" +#error "Please always use macros to include FreeType header files." +#error "Example:" +#error " #include <ft2build.h>" +#error " #include FT_FREETYPE_H" +#endif + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_TYPES_H +#include FT_ERRORS_H + + +FT_BEGIN_HEADER + + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* header_inclusion */ + /* */ + /* <Title> */ + /* FreeType's header inclusion scheme */ + /* */ + /* <Abstract> */ + /* How client applications should include FreeType header files. */ + /* */ + /* <Description> */ + /* To be as flexible as possible (and for historical reasons), */ + /* FreeType uses a very special inclusion scheme to load header */ + /* files, for example */ + /* */ + /* { */ + /* #include <ft2build.h> */ + /* */ + /* #include FT_FREETYPE_H */ + /* #include FT_OUTLINE_H */ + /* } */ + /* */ + /* A compiler and its preprocessor only needs an include path to find */ + /* the file `ft2build.h'; the exact locations and names of the other */ + /* FreeType header files are hidden by preprocessor macro names, */ + /* loaded by `ft2build.h'. The API documentation always gives the */ + /* header macro name needed for a particular function. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* user_allocation */ + /* */ + /* <Title> */ + /* User allocation */ + /* */ + /* <Abstract> */ + /* How client applications should allocate FreeType data structures. */ + /* */ + /* <Description> */ + /* FreeType assumes that structures allocated by the user and passed */ + /* as arguments are zeroed out except for the actual data. In other */ + /* words, it is recommended to use `calloc' (or variants of it) */ + /* instead of `malloc' for allocation. */ + /* */ + /*************************************************************************/ + + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S I C T Y P E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* base_interface */ + /* */ + /* <Title> */ + /* Base Interface */ + /* */ + /* <Abstract> */ + /* The FreeType~2 base font interface. */ + /* */ + /* <Description> */ + /* This section describes the most important public high-level API */ + /* functions of FreeType~2. */ + /* */ + /* <Order> */ + /* FT_Library */ + /* FT_Face */ + /* FT_Size */ + /* FT_GlyphSlot */ + /* FT_CharMap */ + /* FT_Encoding */ + /* FT_ENC_TAG */ + /* */ + /* FT_FaceRec */ + /* */ + /* FT_FACE_FLAG_SCALABLE */ + /* FT_FACE_FLAG_FIXED_SIZES */ + /* FT_FACE_FLAG_FIXED_WIDTH */ + /* FT_FACE_FLAG_HORIZONTAL */ + /* FT_FACE_FLAG_VERTICAL */ + /* FT_FACE_FLAG_COLOR */ + /* FT_FACE_FLAG_SFNT */ + /* FT_FACE_FLAG_CID_KEYED */ + /* FT_FACE_FLAG_TRICKY */ + /* FT_FACE_FLAG_KERNING */ + /* FT_FACE_FLAG_MULTIPLE_MASTERS */ + /* FT_FACE_FLAG_GLYPH_NAMES */ + /* FT_FACE_FLAG_EXTERNAL_STREAM */ + /* FT_FACE_FLAG_HINTER */ + /* */ + /* FT_HAS_HORIZONTAL */ + /* FT_HAS_VERTICAL */ + /* FT_HAS_KERNING */ + /* FT_HAS_FIXED_SIZES */ + /* FT_HAS_GLYPH_NAMES */ + /* FT_HAS_MULTIPLE_MASTERS */ + /* FT_HAS_COLOR */ + /* */ + /* FT_IS_SFNT */ + /* FT_IS_SCALABLE */ + /* FT_IS_FIXED_WIDTH */ + /* FT_IS_CID_KEYED */ + /* FT_IS_TRICKY */ + /* */ + /* FT_STYLE_FLAG_BOLD */ + /* FT_STYLE_FLAG_ITALIC */ + /* */ + /* FT_SizeRec */ + /* FT_Size_Metrics */ + /* */ + /* FT_GlyphSlotRec */ + /* FT_Glyph_Metrics */ + /* FT_SubGlyph */ + /* */ + /* FT_Bitmap_Size */ + /* */ + /* FT_Init_FreeType */ + /* FT_Done_FreeType */ + /* */ + /* FT_New_Face */ + /* FT_Done_Face */ + /* FT_Reference_Face */ + /* FT_New_Memory_Face */ + /* FT_Open_Face */ + /* FT_Open_Args */ + /* FT_Parameter */ + /* FT_Attach_File */ + /* FT_Attach_Stream */ + /* */ + /* FT_Set_Char_Size */ + /* FT_Set_Pixel_Sizes */ + /* FT_Request_Size */ + /* FT_Select_Size */ + /* FT_Size_Request_Type */ + /* FT_Size_RequestRec */ + /* FT_Size_Request */ + /* FT_Set_Transform */ + /* FT_Load_Glyph */ + /* FT_Get_Char_Index */ + /* FT_Get_First_Char */ + /* FT_Get_Next_Char */ + /* FT_Get_Name_Index */ + /* FT_Load_Char */ + /* */ + /* FT_OPEN_MEMORY */ + /* FT_OPEN_STREAM */ + /* FT_OPEN_PATHNAME */ + /* FT_OPEN_DRIVER */ + /* FT_OPEN_PARAMS */ + /* */ + /* FT_LOAD_DEFAULT */ + /* FT_LOAD_RENDER */ + /* FT_LOAD_MONOCHROME */ + /* FT_LOAD_LINEAR_DESIGN */ + /* FT_LOAD_NO_SCALE */ + /* FT_LOAD_NO_HINTING */ + /* FT_LOAD_NO_BITMAP */ + /* FT_LOAD_NO_AUTOHINT */ + /* FT_LOAD_COLOR */ + /* */ + /* FT_LOAD_VERTICAL_LAYOUT */ + /* FT_LOAD_IGNORE_TRANSFORM */ + /* FT_LOAD_FORCE_AUTOHINT */ + /* FT_LOAD_NO_RECURSE */ + /* FT_LOAD_PEDANTIC */ + /* */ + /* FT_LOAD_TARGET_NORMAL */ + /* FT_LOAD_TARGET_LIGHT */ + /* FT_LOAD_TARGET_MONO */ + /* FT_LOAD_TARGET_LCD */ + /* FT_LOAD_TARGET_LCD_V */ + /* */ + /* FT_LOAD_TARGET_MODE */ + /* */ + /* FT_Render_Glyph */ + /* FT_Render_Mode */ + /* FT_Get_Kerning */ + /* FT_Kerning_Mode */ + /* FT_Get_Track_Kerning */ + /* FT_Get_Glyph_Name */ + /* FT_Get_Postscript_Name */ + /* */ + /* FT_CharMapRec */ + /* FT_Select_Charmap */ + /* FT_Set_Charmap */ + /* FT_Get_Charmap_Index */ + /* */ + /* FT_Get_FSType_Flags */ + /* FT_Get_SubGlyph_Info */ + /* */ + /* FT_Face_Internal */ + /* FT_Size_Internal */ + /* FT_Slot_Internal */ + /* */ + /* FT_FACE_FLAG_XXX */ + /* FT_STYLE_FLAG_XXX */ + /* FT_OPEN_XXX */ + /* FT_LOAD_XXX */ + /* FT_LOAD_TARGET_XXX */ + /* FT_SUBGLYPH_FLAG_XXX */ + /* FT_FSTYPE_XXX */ + /* */ + /* FT_HAS_FAST_GLYPHS */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Glyph_Metrics */ + /* */ + /* <Description> */ + /* A structure used to model the metrics of a single glyph. The */ + /* values are expressed in 26.6 fractional pixel format; if the flag */ + /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ + /* are expressed in font units instead. */ + /* */ + /* <Fields> */ + /* width :: */ + /* The glyph's width. */ + /* */ + /* height :: */ + /* The glyph's height. */ + /* */ + /* horiBearingX :: */ + /* Left side bearing for horizontal layout. */ + /* */ + /* horiBearingY :: */ + /* Top side bearing for horizontal layout. */ + /* */ + /* horiAdvance :: */ + /* Advance width for horizontal layout. */ + /* */ + /* vertBearingX :: */ + /* Left side bearing for vertical layout. */ + /* */ + /* vertBearingY :: */ + /* Top side bearing for vertical layout. Larger positive values */ + /* mean further below the vertical glyph origin. */ + /* */ + /* vertAdvance :: */ + /* Advance height for vertical layout. Positive values mean the */ + /* glyph has a positive advance downward. */ + /* */ + /* <Note> */ + /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ + /* dimensions of the hinted glyph (in case hinting is applicable). */ + /* */ + /* Stroking a glyph with an outside border does not increase */ + /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ + /* values to account for the added width and height. */ + /* */ + typedef struct FT_Glyph_Metrics_ + { + FT_Pos width; + FT_Pos height; + + FT_Pos horiBearingX; + FT_Pos horiBearingY; + FT_Pos horiAdvance; + + FT_Pos vertBearingX; + FT_Pos vertBearingY; + FT_Pos vertAdvance; + + } FT_Glyph_Metrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Bitmap_Size */ + /* */ + /* <Description> */ + /* This structure models the metrics of a bitmap strike (i.e., a set */ + /* of glyphs for a given point size and resolution) in a bitmap font. */ + /* It is used for the `available_sizes' field of @FT_Face. */ + /* */ + /* <Fields> */ + /* height :: The vertical distance, in pixels, between two */ + /* consecutive baselines. It is always positive. */ + /* */ + /* width :: The average width, in pixels, of all glyphs in the */ + /* strike. */ + /* */ + /* size :: The nominal size of the strike in 26.6 fractional */ + /* points. This field is not very useful. */ + /* */ + /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ + /* pixels. */ + /* */ + /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ + /* pixels. */ + /* */ + /* <Note> */ + /* Windows FNT: */ + /* The nominal size given in a FNT font is not reliable. Thus when */ + /* the driver finds it incorrect, it sets `size' to some calculated */ + /* values and sets `x_ppem' and `y_ppem' to the pixel width and */ + /* height given in the font, respectively. */ + /* */ + /* TrueType embedded bitmaps: */ + /* `size', `width', and `height' values are not contained in the */ + /* bitmap strike itself. They are computed from the global font */ + /* parameters. */ + /* */ + typedef struct FT_Bitmap_Size_ + { + FT_Short height; + FT_Short width; + + FT_Pos size; + + FT_Pos x_ppem; + FT_Pos y_ppem; + + } FT_Bitmap_Size; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Library */ + /* */ + /* <Description> */ + /* A handle to a FreeType library instance. Each `library' is */ + /* completely independent from the others; it is the `root' of a set */ + /* of objects like fonts, faces, sizes, etc. */ + /* */ + /* It also embeds a memory manager (see @FT_Memory), as well as a */ + /* scan-line converter object (see @FT_Raster). */ + /* */ + /* In multi-threaded applications it is easiest to use one */ + /* `FT_Library' object per thread. In case this is too cumbersome, */ + /* a single `FT_Library' object across threads is possible also */ + /* (since FreeType version 2.5.6), as long as a mutex lock is used */ + /* around @FT_New_Face and @FT_Done_Face. */ + /* */ + /* <Note> */ + /* Library objects are normally created by @FT_Init_FreeType, and */ + /* destroyed with @FT_Done_FreeType. If you need reference-counting */ + /* (cf. @FT_Reference_Library), use @FT_New_Library and */ + /* @FT_Done_Library. */ + /* */ + typedef struct FT_LibraryRec_ *FT_Library; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Module */ + /* */ + /* <Description> */ + /* A handle to a given FreeType module object. Each module can be a */ + /* font driver, a renderer, or anything else that provides services */ + /* to the formers. */ + /* */ + typedef struct FT_ModuleRec_* FT_Module; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Driver */ + /* */ + /* <Description> */ + /* A handle to a given FreeType font driver object. Each font driver */ + /* is a special module capable of creating faces from font files. */ + /* */ + typedef struct FT_DriverRec_* FT_Driver; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Renderer */ + /* */ + /* <Description> */ + /* A handle to a given FreeType renderer. A renderer is a special */ + /* module in charge of converting a glyph image to a bitmap, when */ + /* necessary. Each renderer supports a given glyph image format, and */ + /* one or more target surface depths. */ + /* */ + typedef struct FT_RendererRec_* FT_Renderer; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* base_interface */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Face */ + /* */ + /* <Description> */ + /* A handle to a given typographic face object. A face object models */ + /* a given typeface, in a given style. */ + /* */ + /* <Note> */ + /* Each face object also owns a single @FT_GlyphSlot object, as well */ + /* as one or more @FT_Size objects. */ + /* */ + /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ + /* a given filepathname or a custom input stream. */ + /* */ + /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ + /* */ + /* An `FT_Face' object can only be safely used from one thread at a */ + /* time. Similarly, creation and destruction of `FT_Face' with the */ + /* same @FT_Library object can only be done from one thread at a */ + /* time. On the other hand, functions like @FT_Load_Glyph and its */ + /* siblings are thread-safe and do not need the lock to be held as */ + /* long as the same `FT_Face' object is not used from multiple */ + /* threads at the same time. */ + /* */ + /* <Also> */ + /* See @FT_FaceRec for the publicly accessible fields of a given face */ + /* object. */ + /* */ + typedef struct FT_FaceRec_* FT_Face; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Size */ + /* */ + /* <Description> */ + /* A handle to an object used to model a face scaled to a given */ + /* character size. */ + /* */ + /* <Note> */ + /* Each @FT_Face has an _active_ @FT_Size object that is used by */ + /* functions like @FT_Load_Glyph to determine the scaling */ + /* transformation that in turn is used to load and hint glyphs and */ + /* metrics. */ + /* */ + /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ + /* @FT_Request_Size or even @FT_Select_Size to change the content */ + /* (i.e., the scaling values) of the active @FT_Size. */ + /* */ + /* You can use @FT_New_Size to create additional size objects for a */ + /* given @FT_Face, but they won't be used by other functions until */ + /* you activate it through @FT_Activate_Size. Only one size can be */ + /* activated at any given time per face. */ + /* */ + /* <Also> */ + /* See @FT_SizeRec for the publicly accessible fields of a given size */ + /* object. */ + /* */ + typedef struct FT_SizeRec_* FT_Size; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_GlyphSlot */ + /* */ + /* <Description> */ + /* A handle to a given `glyph slot'. A slot is a container where it */ + /* is possible to load any of the glyphs contained in its parent */ + /* face. */ + /* */ + /* In other words, each time you call @FT_Load_Glyph or */ + /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ + /* i.e., the glyph's metrics, its image (bitmap or outline), and */ + /* other control information. */ + /* */ + /* <Also> */ + /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ + /* */ + typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_CharMap */ + /* */ + /* <Description> */ + /* A handle to a given character map. A charmap is used to translate */ + /* character codes in a given encoding into glyph indexes for its */ + /* parent's face. Some font formats may provide several charmaps per */ + /* font. */ + /* */ + /* Each face object owns zero or more charmaps, but only one of them */ + /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */ + /* */ + /* The list of available charmaps in a face is available through the */ + /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ + /* */ + /* The currently active charmap is available as `face->charmap'. */ + /* You should call @FT_Set_Charmap to change it. */ + /* */ + /* <Note> */ + /* When a new face is created (either through @FT_New_Face or */ + /* @FT_Open_Face), the library looks for a Unicode charmap within */ + /* the list and automatically activates it. */ + /* */ + /* <Also> */ + /* See @FT_CharMapRec for the publicly accessible fields of a given */ + /* character map. */ + /* */ + typedef struct FT_CharMapRec_* FT_CharMap; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_ENC_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags into an unsigned long. It is */ + /* used to define `encoding' identifiers (see @FT_Encoding). */ + /* */ + /* <Note> */ + /* Since many 16-bit compilers don't like 32-bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* { */ + /* #define FT_ENC_TAG( value, a, b, c, d ) value */ + /* } */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ + +#ifndef FT_ENC_TAG +#define FT_ENC_TAG( value, a, b, c, d ) \ + value = ( ( (FT_UInt32)(a) << 24 ) | \ + ( (FT_UInt32)(b) << 16 ) | \ + ( (FT_UInt32)(c) << 8 ) | \ + (FT_UInt32)(d) ) + +#endif /* FT_ENC_TAG */ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Encoding */ + /* */ + /* <Description> */ + /* An enumeration used to specify character sets supported by */ + /* charmaps. Used in the @FT_Select_Charmap API function. */ + /* */ + /* <Note> */ + /* Despite the name, this enumeration lists specific character */ + /* repertories (i.e., charsets), and not text encoding methods (e.g., */ + /* UTF-8, UTF-16, etc.). */ + /* */ + /* Other encodings might be defined in the future. */ + /* */ + /* <Values> */ + /* FT_ENCODING_NONE :: */ + /* The encoding value~0 is reserved. */ + /* */ + /* FT_ENCODING_UNICODE :: */ + /* Corresponds to the Unicode character set. This value covers */ + /* all versions of the Unicode repertoire, including ASCII and */ + /* Latin-1. Most fonts include a Unicode charmap, but not all */ + /* of them. */ + /* */ + /* For example, if you want to access Unicode value U+1F028 (and */ + /* the font contains it), use value 0x1F028 as the input value for */ + /* @FT_Get_Char_Index. */ + /* */ + /* FT_ENCODING_MS_SYMBOL :: */ + /* Corresponds to the Microsoft Symbol encoding, used to encode */ + /* mathematical symbols and wingdings. For more information, see */ + /* `http://www.microsoft.com/typography/otspec/recom.htm', */ + /* `http://www.kostis.net/charsets/symbol.htm', and */ + /* `http://www.kostis.net/charsets/wingding.htm'. */ + /* */ + /* This encoding uses character codes from the PUA (Private Unicode */ + /* Area) in the range U+F020-U+F0FF. */ + /* */ + /* FT_ENCODING_SJIS :: */ + /* Corresponds to Japanese SJIS encoding. More info at */ + /* at `http://en.wikipedia.org/wiki/Shift_JIS'. */ + /* See note on multi-byte encodings below. */ + /* */ + /* FT_ENCODING_GB2312 :: */ + /* Corresponds to an encoding system for Simplified Chinese as used */ + /* used in mainland China. */ + /* */ + /* FT_ENCODING_BIG5 :: */ + /* Corresponds to an encoding system for Traditional Chinese as */ + /* used in Taiwan and Hong Kong. */ + /* */ + /* FT_ENCODING_WANSUNG :: */ + /* Corresponds to the Korean encoding system known as Wansung. */ + /* For more information see */ + /* `https://msdn.microsoft.com/en-US/goglobal/cc305154'. */ + /* */ + /* FT_ENCODING_JOHAB :: */ + /* The Korean standard character set (KS~C 5601-1992), which */ + /* corresponds to MS Windows code page 1361. This character set */ + /* includes all possible Hangeul character combinations. */ + /* */ + /* FT_ENCODING_ADOBE_LATIN_1 :: */ + /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ + /* PostScript font. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_ADOBE_STANDARD :: */ + /* Corresponds to the Adobe Standard encoding, as found in Type~1, */ + /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ + /* codes. */ + /* */ + /* FT_ENCODING_ADOBE_EXPERT :: */ + /* Corresponds to the Adobe Expert encoding, as found in Type~1, */ + /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ + /* codes. */ + /* */ + /* FT_ENCODING_ADOBE_CUSTOM :: */ + /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ + /* OpenType/CFF fonts. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_APPLE_ROMAN :: */ + /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */ + /* and OpenType fonts contain a charmap for this encoding, since */ + /* older versions of Mac OS are able to use it. */ + /* */ + /* FT_ENCODING_OLD_LATIN_2 :: */ + /* This value is deprecated and was never used nor reported by */ + /* FreeType. Don't use or test for it. */ + /* */ + /* FT_ENCODING_MS_SJIS :: */ + /* Same as FT_ENCODING_SJIS. Deprecated. */ + /* */ + /* FT_ENCODING_MS_GB2312 :: */ + /* Same as FT_ENCODING_GB2312. Deprecated. */ + /* */ + /* FT_ENCODING_MS_BIG5 :: */ + /* Same as FT_ENCODING_BIG5. Deprecated. */ + /* */ + /* FT_ENCODING_MS_WANSUNG :: */ + /* Same as FT_ENCODING_WANSUNG. Deprecated. */ + /* */ + /* FT_ENCODING_MS_JOHAB :: */ + /* Same as FT_ENCODING_JOHAB. Deprecated. */ + /* */ + /* <Note> */ + /* By default, FreeType automatically synthesizes a Unicode charmap */ + /* for PostScript fonts, using their glyph names dictionaries. */ + /* However, it also reports the encodings defined explicitly in the */ + /* font file, for the cases when they are needed, with the Adobe */ + /* values as well. */ + /* */ + /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ + /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ + /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ + /* which encoding is really present. If, for example, the */ + /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ + /* the font is encoded in KOI8-R. */ + /* */ + /* FT_ENCODING_NONE is always set (with a single exception) by the */ + /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ + /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ + /* which encoding is really present. For example, */ + /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ + /* Russian). */ + /* */ + /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ + /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */ + /* FT_ENCODING_APPLE_ROMAN). */ + /* */ + /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ + /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ + /* be needed to be able to distinguish Apple encoding variants. See */ + /* */ + /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ + /* */ + /* to get an idea how to do that. Basically, if the language ID */ + /* is~0, don't use it, otherwise subtract 1 from the language ID. */ + /* Then examine `encoding_id'. If, for example, `encoding_id' is */ + /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */ + /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ + /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */ + /* variant the Arabic encoding. */ + /* */ + typedef enum FT_Encoding_ + { + FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), + + FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), + FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), + + FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), + FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ), + FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), + FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), + FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), + + /* for backwards compatibility */ + FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, + FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312, + FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, + FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, + FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, + + FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), + + FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), + + FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) + + } FT_Encoding; + + + /* these constants are deprecated; use the corresponding `FT_Encoding' */ + /* values instead */ +#define ft_encoding_none FT_ENCODING_NONE +#define ft_encoding_unicode FT_ENCODING_UNICODE +#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL +#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 +#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 +#define ft_encoding_sjis FT_ENCODING_SJIS +#define ft_encoding_gb2312 FT_ENCODING_GB2312 +#define ft_encoding_big5 FT_ENCODING_BIG5 +#define ft_encoding_wansung FT_ENCODING_WANSUNG +#define ft_encoding_johab FT_ENCODING_JOHAB + +#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD +#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT +#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM +#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_CharMapRec */ + /* */ + /* <Description> */ + /* The base charmap structure. */ + /* */ + /* <Fields> */ + /* face :: A handle to the parent face object. */ + /* */ + /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ + /* this with @FT_Select_Charmap. */ + /* */ + /* platform_id :: An ID number describing the platform for the */ + /* following encoding ID. This comes directly from */ + /* the TrueType specification and should be emulated */ + /* for other formats. */ + /* */ + /* encoding_id :: A platform specific encoding number. This also */ + /* comes from the TrueType specification and should be */ + /* emulated similarly. */ + /* */ + typedef struct FT_CharMapRec_ + { + FT_Face face; + FT_Encoding encoding; + FT_UShort platform_id; + FT_UShort encoding_id; + + } FT_CharMapRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S E O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Face_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Face_InternalRec' structure, used to */ + /* model private data of a given @FT_Face object. */ + /* */ + /* This structure might change between releases of FreeType~2 and is */ + /* not generally available to client applications. */ + /* */ + typedef struct FT_Face_InternalRec_* FT_Face_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_FaceRec */ + /* */ + /* <Description> */ + /* FreeType root face class structure. A face object models a */ + /* typeface in a font file. */ + /* */ + /* <Fields> */ + /* num_faces :: The number of faces in the font file. Some */ + /* font formats can have multiple faces in */ + /* a font file. */ + /* */ + /* face_index :: This field holds two different values. */ + /* Bits 0-15 are the index of the face in the */ + /* font file (starting with value~0). They */ + /* are set to~0 if there is only one face in */ + /* the font file. */ + /* */ + /* Bits 16-30 are relevant to GX variation */ + /* fonts only, holding the named instance */ + /* index for the current face index (starting */ + /* with value~1; value~0 indicates font access */ + /* without GX variation data). For non-GX */ + /* fonts, bits 16-30 are ignored. If we have */ + /* the third named instance of face~4, say, */ + /* `face_index' is set to 0x00030004. */ + /* */ + /* Bit 31 is always zero (this is, */ + /* `face_index' is always a positive value). */ + /* */ + /* face_flags :: A set of bit flags that give important */ + /* information about the face; see */ + /* @FT_FACE_FLAG_XXX for the details. */ + /* */ + /* style_flags :: The lower 16~bits contain a set of bit */ + /* flags indicating the style of the face; see */ + /* @FT_STYLE_FLAG_XXX for the details. Bits */ + /* 16-30 hold the number of named instances */ + /* available for the current face if we have a */ + /* GX variation (sub)font. Bit 31 is always */ + /* zero (this is, `style_flags' is always a */ + /* positive value). */ + /* */ + /* num_glyphs :: The number of glyphs in the face. If the */ + /* face is scalable and has sbits (see */ + /* `num_fixed_sizes'), it is set to the number */ + /* of outline glyphs. */ + /* */ + /* For CID-keyed fonts, this value gives the */ + /* highest CID used in the font. */ + /* */ + /* family_name :: The face's family name. This is an ASCII */ + /* string, usually in English, that describes */ + /* the typeface's family (like `Times New */ + /* Roman', `Bodoni', `Garamond', etc). This */ + /* is a least common denominator used to list */ + /* fonts. Some formats (TrueType & OpenType) */ + /* provide localized and Unicode versions of */ + /* this string. Applications should use the */ + /* format specific interface to access them. */ + /* Can be NULL (e.g., in fonts embedded in a */ + /* PDF file). */ + /* */ + /* In case the font doesn't provide a specific */ + /* family name entry, FreeType tries to */ + /* synthesize one, deriving it from other name */ + /* entries. */ + /* */ + /* style_name :: The face's style name. This is an ASCII */ + /* string, usually in English, that describes */ + /* the typeface's style (like `Italic', */ + /* `Bold', `Condensed', etc). Not all font */ + /* formats provide a style name, so this field */ + /* is optional, and can be set to NULL. As */ + /* for `family_name', some formats provide */ + /* localized and Unicode versions of this */ + /* string. Applications should use the format */ + /* specific interface to access them. */ + /* */ + /* num_fixed_sizes :: The number of bitmap strikes in the face. */ + /* Even if the face is scalable, there might */ + /* still be bitmap strikes, which are called */ + /* `sbits' in that case. */ + /* */ + /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ + /* strikes in the face. It is set to NULL if */ + /* there is no bitmap strike. */ + /* */ + /* num_charmaps :: The number of charmaps in the face. */ + /* */ + /* charmaps :: An array of the charmaps of the face. */ + /* */ + /* generic :: A field reserved for client uses. See the */ + /* @FT_Generic type description. */ + /* */ + /* bbox :: The font bounding box. Coordinates are */ + /* expressed in font units (see */ + /* `units_per_EM'). The box is large enough */ + /* to contain any glyph from the font. Thus, */ + /* `bbox.yMax' can be seen as the `maximum */ + /* ascender', and `bbox.yMin' as the `minimum */ + /* descender'. Only relevant for scalable */ + /* formats. */ + /* */ + /* Note that the bounding box might be off by */ + /* (at least) one pixel for hinted fonts. See */ + /* @FT_Size_Metrics for further discussion. */ + /* */ + /* units_per_EM :: The number of font units per EM square for */ + /* this face. This is typically 2048 for */ + /* TrueType fonts, and 1000 for Type~1 fonts. */ + /* Only relevant for scalable formats. */ + /* */ + /* ascender :: The typographic ascender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMax'. Only relevant for scalable */ + /* formats. */ + /* */ + /* descender :: The typographic descender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMin'. Note that this field is */ + /* usually negative. Only relevant for */ + /* scalable formats. */ + /* */ + /* height :: This value is the vertical distance */ + /* between two consecutive baselines, */ + /* expressed in font units. It is always */ + /* positive. Only relevant for scalable */ + /* formats. */ + /* */ + /* If you want the global glyph height, use */ + /* `ascender - descender'. */ + /* */ + /* max_advance_width :: The maximum advance width, in font units, */ + /* for all glyphs in this face. This can be */ + /* used to make word wrapping computations */ + /* faster. Only relevant for scalable */ + /* formats. */ + /* */ + /* max_advance_height :: The maximum advance height, in font units, */ + /* for all glyphs in this face. This is only */ + /* relevant for vertical layouts, and is set */ + /* to `height' for fonts that do not provide */ + /* vertical metrics. Only relevant for */ + /* scalable formats. */ + /* */ + /* underline_position :: The position, in font units, of the */ + /* underline line for this face. It is the */ + /* center of the underlining stem. Only */ + /* relevant for scalable formats. */ + /* */ + /* underline_thickness :: The thickness, in font units, of the */ + /* underline for this face. Only relevant for */ + /* scalable formats. */ + /* */ + /* glyph :: The face's associated glyph slot(s). */ + /* */ + /* size :: The current active size for this face. */ + /* */ + /* charmap :: The current active charmap for this face. */ + /* */ + /* <Note> */ + /* Fields may be changed after a call to @FT_Attach_File or */ + /* @FT_Attach_Stream. */ + /* */ + typedef struct FT_FaceRec_ + { + FT_Long num_faces; + FT_Long face_index; + + FT_Long face_flags; + FT_Long style_flags; + + FT_Long num_glyphs; + + FT_String* family_name; + FT_String* style_name; + + FT_Int num_fixed_sizes; + FT_Bitmap_Size* available_sizes; + + FT_Int num_charmaps; + FT_CharMap* charmaps; + + FT_Generic generic; + + /*# The following member variables (down to `underline_thickness') */ + /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ + /*# for bitmap fonts. */ + FT_BBox bbox; + + FT_UShort units_per_EM; + FT_Short ascender; + FT_Short descender; + FT_Short height; + + FT_Short max_advance_width; + FT_Short max_advance_height; + + FT_Short underline_position; + FT_Short underline_thickness; + + FT_GlyphSlot glyph; + FT_Size size; + FT_CharMap charmap; + + /*@private begin */ + + FT_Driver driver; + FT_Memory memory; + FT_Stream stream; + + FT_ListRec sizes_list; + + FT_Generic autohint; /* face-specific auto-hinter data */ + void* extensions; /* unused */ + + FT_Face_Internal internal; + + /*@private end */ + + } FT_FaceRec; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_FACE_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the `face_flags' field of the */ + /* @FT_FaceRec structure. They inform client applications of */ + /* properties of the corresponding face. */ + /* */ + /* <Values> */ + /* FT_FACE_FLAG_SCALABLE :: */ + /* Indicates that the face contains outline glyphs. This doesn't */ + /* prevent bitmap strikes, i.e., a face can have both this and */ + /* and @FT_FACE_FLAG_FIXED_SIZES set. */ + /* */ + /* FT_FACE_FLAG_FIXED_SIZES :: */ + /* Indicates that the face contains bitmap strikes. See also the */ + /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ + /* */ + /* FT_FACE_FLAG_FIXED_WIDTH :: */ + /* Indicates that the face contains fixed-width characters (like */ + /* Courier, Lucido, MonoType, etc.). */ + /* */ + /* FT_FACE_FLAG_SFNT :: */ + /* Indicates that the face uses the `sfnt' storage scheme. For */ + /* now, this means TrueType and OpenType. */ + /* */ + /* FT_FACE_FLAG_HORIZONTAL :: */ + /* Indicates that the face contains horizontal glyph metrics. This */ + /* should be set for all common formats. */ + /* */ + /* FT_FACE_FLAG_VERTICAL :: */ + /* Indicates that the face contains vertical glyph metrics. This */ + /* is only available in some formats, not all of them. */ + /* */ + /* FT_FACE_FLAG_KERNING :: */ + /* Indicates that the face contains kerning information. If set, */ + /* the kerning distance can be retrieved through the function */ + /* @FT_Get_Kerning. Otherwise the function always return the */ + /* vector (0,0). Note that FreeType doesn't handle kerning data */ + /* from the `GPOS' table (as present in some OpenType fonts). */ + /* */ + /* FT_FACE_FLAG_FAST_GLYPHS :: */ + /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ + /* */ + /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ + /* Indicates that the font contains multiple masters and is capable */ + /* of interpolating between them. See the multiple-masters */ + /* specific API for details. */ + /* */ + /* FT_FACE_FLAG_GLYPH_NAMES :: */ + /* Indicates that the font contains glyph names that can be */ + /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */ + /* fonts contain broken glyph name tables. Use the function */ + /* @FT_Has_PS_Glyph_Names when needed. */ + /* */ + /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ + /* Used internally by FreeType to indicate that a face's stream was */ + /* provided by the client application and should not be destroyed */ + /* when @FT_Done_Face is called. Don't read or test this flag. */ + /* */ + /* FT_FACE_FLAG_HINTER :: */ + /* Set if the font driver has a hinting machine of its own. For */ + /* example, with TrueType fonts, it makes sense to use data from */ + /* the SFNT `gasp' table only if the native TrueType hinting engine */ + /* (with the bytecode interpreter) is available and active. */ + /* */ + /* FT_FACE_FLAG_CID_KEYED :: */ + /* Set if the font is CID-keyed. In that case, the font is not */ + /* accessed by glyph indices but by CID values. For subsetted */ + /* CID-keyed fonts this has the consequence that not all index */ + /* values are a valid argument to FT_Load_Glyph. Only the CID */ + /* values for which corresponding glyphs in the subsetted font */ + /* exist make FT_Load_Glyph return successfully; in all other cases */ + /* you get an `FT_Err_Invalid_Argument' error. */ + /* */ + /* Note that CID-keyed fonts that are in an SFNT wrapper don't */ + /* have this flag set since the glyphs are accessed in the normal */ + /* way (using contiguous indices); the `CID-ness' isn't visible to */ + /* the application. */ + /* */ + /* FT_FACE_FLAG_TRICKY :: */ + /* Set if the font is `tricky', this is, it always needs the */ + /* font format's native hinting engine to get a reasonable result. */ + /* A typical example is the Chinese font `mingli.ttf' that uses */ + /* TrueType bytecode instructions to move and scale all of its */ + /* subglyphs. */ + /* */ + /* It is not possible to auto-hint such fonts using */ + /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ + /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ + /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ + /* probably never want this except for demonstration purposes. */ + /* */ + /* Currently, there are about a dozen TrueType fonts in the list of */ + /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ + /* */ + /* FT_FACE_FLAG_COLOR :: */ + /* Set if the font has color glyph tables. To access color glyphs */ + /* use @FT_LOAD_COLOR. */ + /* */ +#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) +#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) +#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) +#define FT_FACE_FLAG_SFNT ( 1L << 3 ) +#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) +#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) +#define FT_FACE_FLAG_KERNING ( 1L << 6 ) +#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) +#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) +#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) +#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) +#define FT_FACE_FLAG_HINTER ( 1L << 11 ) +#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) +#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) +#define FT_FACE_FLAG_COLOR ( 1L << 14 ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_HORIZONTAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains + * horizontal metrics (this is true for all font formats though). + * + * @also: + * @FT_HAS_VERTICAL can be used to check for vertical metrics. + * + */ +#define FT_HAS_HORIZONTAL( face ) \ + ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_VERTICAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains real + * vertical metrics (and not only synthesized ones). + * + */ +#define FT_HAS_VERTICAL( face ) \ + ( face->face_flags & FT_FACE_FLAG_VERTICAL ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_KERNING( face ) + * + * @description: + * A macro that returns true whenever a face object contains kerning + * data that can be accessed with @FT_Get_Kerning. + * + */ +#define FT_HAS_KERNING( face ) \ + ( face->face_flags & FT_FACE_FLAG_KERNING ) + + + /************************************************************************* + * + * @macro: + * FT_IS_SCALABLE( face ) + * + * @description: + * A macro that returns true whenever a face object contains a scalable + * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, + * and PFR font formats. + * + */ +#define FT_IS_SCALABLE( face ) \ + ( face->face_flags & FT_FACE_FLAG_SCALABLE ) + + + /************************************************************************* + * + * @macro: + * FT_IS_SFNT( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font + * whose format is based on the SFNT storage scheme. This usually + * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded + * bitmap fonts. + * + * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and + * @FT_TRUETYPE_TABLES_H are available. + * + */ +#define FT_IS_SFNT( face ) \ + ( face->face_flags & FT_FACE_FLAG_SFNT ) + + + /************************************************************************* + * + * @macro: + * FT_IS_FIXED_WIDTH( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font face + * that contains fixed-width (or `monospace', `fixed-pitch', etc.) + * glyphs. + * + */ +#define FT_IS_FIXED_WIDTH( face ) \ + ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_FIXED_SIZES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * embedded bitmaps. See the `available_sizes' field of the + * @FT_FaceRec structure. + * + */ +#define FT_HAS_FIXED_SIZES( face ) \ + ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_FAST_GLYPHS( face ) + * + * @description: + * Deprecated. + * + */ +#define FT_HAS_FAST_GLYPHS( face ) 0 + + + /************************************************************************* + * + * @macro: + * FT_HAS_GLYPH_NAMES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some glyph + * names that can be accessed through @FT_Get_Glyph_Name. + * + */ +#define FT_HAS_GLYPH_NAMES( face ) \ + ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_MULTIPLE_MASTERS( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H + * are then available to choose the exact design you want. + * + */ +#define FT_HAS_MULTIPLE_MASTERS( face ) \ + ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) + + + /************************************************************************* + * + * @macro: + * FT_IS_CID_KEYED( face ) + * + * @description: + * A macro that returns true whenever a face object contains a CID-keyed + * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more + * details. + * + * If this macro is true, all functions defined in @FT_CID_H are + * available. + * + */ +#define FT_IS_CID_KEYED( face ) \ + ( face->face_flags & FT_FACE_FLAG_CID_KEYED ) + + + /************************************************************************* + * + * @macro: + * FT_IS_TRICKY( face ) + * + * @description: + * A macro that returns true whenever a face represents a `tricky' font. + * See the discussion of @FT_FACE_FLAG_TRICKY for more details. + * + */ +#define FT_IS_TRICKY( face ) \ + ( face->face_flags & FT_FACE_FLAG_TRICKY ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_COLOR( face ) + * + * @description: + * A macro that returns true whenever a face object contains + * tables for color glyphs. + * + */ +#define FT_HAS_COLOR( face ) \ + ( face->face_flags & FT_FACE_FLAG_COLOR ) + + + /*************************************************************************/ + /* */ + /* <Const> */ + /* FT_STYLE_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used to indicate the style of a given face. */ + /* These are used in the `style_flags' field of @FT_FaceRec. */ + /* */ + /* <Values> */ + /* FT_STYLE_FLAG_ITALIC :: */ + /* Indicates that a given face style is italic or oblique. */ + /* */ + /* FT_STYLE_FLAG_BOLD :: */ + /* Indicates that a given face is bold. */ + /* */ + /* <Note> */ + /* The style information as provided by FreeType is very basic. More */ + /* details are beyond the scope and should be done on a higher level */ + /* (for example, by analyzing various fields of the `OS/2' table in */ + /* SFNT based fonts). */ + /* */ +#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) +#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Size_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ + /* model private data of a given @FT_Size object. */ + /* */ + typedef struct FT_Size_InternalRec_* FT_Size_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_Metrics */ + /* */ + /* <Description> */ + /* The size metrics structure gives the metrics of a size object. */ + /* */ + /* <Fields> */ + /* x_ppem :: The width of the scaled EM square in pixels, hence */ + /* the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal width'. */ + /* */ + /* y_ppem :: The height of the scaled EM square in pixels, */ + /* hence the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal height'. */ + /* */ + /* x_scale :: A 16.16 fractional scaling value used to convert */ + /* horizontal metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ + /* */ + /* y_scale :: A 16.16 fractional scaling value used to convert */ + /* vertical metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ + /* */ + /* ascender :: The ascender in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ + /* */ + /* descender :: The descender in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ + /* */ + /* height :: The height in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ + /* */ + /* max_advance :: The maximum advance width in 26.6 fractional */ + /* pixels. See @FT_FaceRec for the details. */ + /* */ + /* <Note> */ + /* The scaling values, if relevant, are determined first during a */ + /* size changing operation. The remaining fields are then set by the */ + /* driver. For scalable formats, they are usually set to scaled */ + /* values of the corresponding fields in @FT_FaceRec. */ + /* */ + /* Note that due to glyph hinting, these values might not be exact */ + /* for certain fonts. Thus they must be treated as unreliable */ + /* with an error margin of at least one pixel! */ + /* */ + /* Indeed, the only way to get the exact metrics is to render _all_ */ + /* glyphs. As this would be a definite performance hit, it is up to */ + /* client applications to perform such computations. */ + /* */ + /* The FT_Size_Metrics structure is valid for bitmap fonts also. */ + /* */ + typedef struct FT_Size_Metrics_ + { + FT_UShort x_ppem; /* horizontal pixels per EM */ + FT_UShort y_ppem; /* vertical pixels per EM */ + + FT_Fixed x_scale; /* scaling values used to convert font */ + FT_Fixed y_scale; /* units to 26.6 fractional pixels */ + + FT_Pos ascender; /* ascender in 26.6 frac. pixels */ + FT_Pos descender; /* descender in 26.6 frac. pixels */ + FT_Pos height; /* text height in 26.6 frac. pixels */ + FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ + + } FT_Size_Metrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SizeRec */ + /* */ + /* <Description> */ + /* FreeType root size class structure. A size object models a face */ + /* object at a given size. */ + /* */ + /* <Fields> */ + /* face :: Handle to the parent face object. */ + /* */ + /* generic :: A typeless pointer, unused by the FreeType library or */ + /* any of its drivers. It can be used by client */ + /* applications to link their own data to each size */ + /* object. */ + /* */ + /* metrics :: Metrics for this size object. This field is read-only. */ + /* */ + typedef struct FT_SizeRec_ + { + FT_Face face; /* parent face object */ + FT_Generic generic; /* generic pointer for client uses */ + FT_Size_Metrics metrics; /* size metrics */ + FT_Size_Internal internal; + + } FT_SizeRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SubGlyph */ + /* */ + /* <Description> */ + /* The subglyph structure is an internal object used to describe */ + /* subglyphs (for example, in the case of composites). */ + /* */ + /* <Note> */ + /* The subglyph implementation is not part of the high-level API, */ + /* hence the forward structure declaration. */ + /* */ + /* You can however retrieve subglyph information with */ + /* @FT_Get_SubGlyph_Info. */ + /* */ + typedef struct FT_SubGlyphRec_* FT_SubGlyph; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Slot_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ + /* model private data of a given @FT_GlyphSlot object. */ + /* */ + typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_GlyphSlotRec */ + /* */ + /* <Description> */ + /* FreeType root glyph slot class structure. A glyph slot is a */ + /* container where individual glyphs can be loaded, be they in */ + /* outline or bitmap format. */ + /* */ + /* <Fields> */ + /* library :: A handle to the FreeType library instance */ + /* this slot belongs to. */ + /* */ + /* face :: A handle to the parent face object. */ + /* */ + /* next :: In some cases (like some font tools), several */ + /* glyph slots per face object can be a good */ + /* thing. As this is rare, the glyph slots are */ + /* listed through a direct, single-linked list */ + /* using its `next' field. */ + /* */ + /* generic :: A typeless pointer unused by the FreeType */ + /* library or any of its drivers. It can be */ + /* used by client applications to link their own */ + /* data to each glyph slot object. */ + /* */ + /* metrics :: The metrics of the last loaded glyph in the */ + /* slot. The returned values depend on the last */ + /* load flags (see the @FT_Load_Glyph API */ + /* function) and can be expressed either in 26.6 */ + /* fractional pixels or font units. */ + /* */ + /* Note that even when the glyph image is */ + /* transformed, the metrics are not. */ + /* */ + /* linearHoriAdvance :: The advance width of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ + /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ + /* */ + /* linearVertAdvance :: The advance height of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ + /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ + /* */ + /* advance :: This shorthand is, depending on */ + /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ + /* (hinted) advance width for the glyph, in 26.6 */ + /* fractional pixel format. As specified with */ + /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ + /* `horiAdvance' or the `vertAdvance' value of */ + /* `metrics' field. */ + /* */ + /* format :: This field indicates the format of the image */ + /* contained in the glyph slot. Typically */ + /* @FT_GLYPH_FORMAT_BITMAP, */ + /* @FT_GLYPH_FORMAT_OUTLINE, or */ + /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */ + /* possible. */ + /* */ + /* bitmap :: This field is used as a bitmap descriptor */ + /* when the slot format is */ + /* @FT_GLYPH_FORMAT_BITMAP. Note that the */ + /* address and content of the bitmap buffer can */ + /* change between calls of @FT_Load_Glyph and a */ + /* few other functions. */ + /* */ + /* bitmap_left :: The bitmap's left bearing expressed in */ + /* integer pixels. Only valid if the format is */ + /* @FT_GLYPH_FORMAT_BITMAP, this is, if the */ + /* glyph slot contains a bitmap. */ + /* */ + /* bitmap_top :: The bitmap's top bearing expressed in integer */ + /* pixels. Remember that this is the distance */ + /* from the baseline to the top-most glyph */ + /* scanline, upwards y~coordinates being */ + /* *positive*. */ + /* */ + /* outline :: The outline descriptor for the current glyph */ + /* image if its format is */ + /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ + /* loaded, `outline' can be transformed, */ + /* distorted, embolded, etc. However, it must */ + /* not be freed. */ + /* */ + /* num_subglyphs :: The number of subglyphs in a composite glyph. */ + /* This field is only valid for the composite */ + /* glyph format that should normally only be */ + /* loaded with the @FT_LOAD_NO_RECURSE flag. */ + /* */ + /* subglyphs :: An array of subglyph descriptors for */ + /* composite glyphs. There are `num_subglyphs' */ + /* elements in there. Currently internal to */ + /* FreeType. */ + /* */ + /* control_data :: Certain font drivers can also return the */ + /* control data for a given glyph image (e.g. */ + /* TrueType bytecode, Type~1 charstrings, etc.). */ + /* This field is a pointer to such data. */ + /* */ + /* control_len :: This is the length in bytes of the control */ + /* data. */ + /* */ + /* other :: Really wicked formats can use this pointer to */ + /* present their own glyph image to client */ + /* applications. Note that the application */ + /* needs to know about the image format. */ + /* */ + /* lsb_delta :: The difference between hinted and unhinted */ + /* left side bearing while auto-hinting is */ + /* active. Zero otherwise. */ + /* */ + /* rsb_delta :: The difference between hinted and unhinted */ + /* right side bearing while auto-hinting is */ + /* active. Zero otherwise. */ + /* */ + /* <Note> */ + /* If @FT_Load_Glyph is called with default flags (see */ + /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ + /* its native format (e.g., an outline glyph for TrueType and Type~1 */ + /* formats). */ + /* */ + /* This image can later be converted into a bitmap by calling */ + /* @FT_Render_Glyph. This function finds the current renderer for */ + /* the native image's format, then invokes it. */ + /* */ + /* The renderer is in charge of transforming the native image through */ + /* the slot's face transformation fields, then converting it into a */ + /* bitmap that is returned in `slot->bitmap'. */ + /* */ + /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ + /* to specify the position of the bitmap relative to the current pen */ + /* position (e.g., coordinates (0,0) on the baseline). Of course, */ + /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ + /* */ + /* <Note> */ + /* Here is a small pseudo code fragment that shows how to use */ + /* `lsb_delta' and `rsb_delta': */ + /* */ + /* { */ + /* FT_Pos origin_x = 0; */ + /* FT_Pos prev_rsb_delta = 0; */ + /* */ + /* */ + /* for all glyphs do */ + /* <compute kern between current and previous glyph and add it to */ + /* `origin_x'> */ + /* */ + /* <load glyph with `FT_Load_Glyph'> */ + /* */ + /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */ + /* origin_x -= 64; */ + /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */ + /* origin_x += 64; */ + /* */ + /* prev_rsb_delta = face->glyph->rsb_delta; */ + /* */ + /* <save glyph image, or render glyph, or ...> */ + /* */ + /* origin_x += face->glyph->advance.x; */ + /* endfor */ + /* } */ + /* */ + typedef struct FT_GlyphSlotRec_ + { + FT_Library library; + FT_Face face; + FT_GlyphSlot next; + FT_UInt reserved; /* retained for binary compatibility */ + FT_Generic generic; + + FT_Glyph_Metrics metrics; + FT_Fixed linearHoriAdvance; + FT_Fixed linearVertAdvance; + FT_Vector advance; + + FT_Glyph_Format format; + + FT_Bitmap bitmap; + FT_Int bitmap_left; + FT_Int bitmap_top; + + FT_Outline outline; + + FT_UInt num_subglyphs; + FT_SubGlyph subglyphs; + + void* control_data; + long control_len; + + FT_Pos lsb_delta; + FT_Pos rsb_delta; + + void* other; + + FT_Slot_Internal internal; + + } FT_GlyphSlotRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* F U N C T I O N S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Init_FreeType */ + /* */ + /* <Description> */ + /* Initialize a new FreeType library object. The set of modules */ + /* that are registered by this function is determined at build time. */ + /* */ + /* <Output> */ + /* alibrary :: A handle to a new library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* In case you want to provide your own memory allocating routines, */ + /* use @FT_New_Library instead, followed by a call to */ + /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */ + /* */ + /* See the documentation of @FT_Library and @FT_Face for */ + /* multi-threading issues. */ + /* */ + /* If you need reference-counting (cf. @FT_Reference_Library), use */ + /* @FT_New_Library and @FT_Done_Library. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Init_FreeType( FT_Library *alibrary ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_FreeType */ + /* */ + /* <Description> */ + /* Destroy a given FreeType library object and all of its children, */ + /* including resources, drivers, faces, sizes, etc. */ + /* */ + /* <Input> */ + /* library :: A handle to the target library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_FreeType( FT_Library library ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_OPEN_XXX */ + /* */ + /* <Description> */ + /* A list of bit field constants used within the `flags' field of the */ + /* @FT_Open_Args structure. */ + /* */ + /* <Values> */ + /* FT_OPEN_MEMORY :: This is a memory-based stream. */ + /* */ + /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ + /* */ + /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ + /* name. */ + /* */ + /* FT_OPEN_DRIVER :: Use the `driver' field. */ + /* */ + /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ + /* */ + /* <Note> */ + /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ + /* flags are mutually exclusive. */ + /* */ +#define FT_OPEN_MEMORY 0x1 +#define FT_OPEN_STREAM 0x2 +#define FT_OPEN_PATHNAME 0x4 +#define FT_OPEN_DRIVER 0x8 +#define FT_OPEN_PARAMS 0x10 + + + /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ + /* values instead */ +#define ft_open_memory FT_OPEN_MEMORY +#define ft_open_stream FT_OPEN_STREAM +#define ft_open_pathname FT_OPEN_PATHNAME +#define ft_open_driver FT_OPEN_DRIVER +#define ft_open_params FT_OPEN_PARAMS + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Parameter */ + /* */ + /* <Description> */ + /* A simple structure used to pass more or less generic parameters to */ + /* @FT_Open_Face. */ + /* */ + /* <Fields> */ + /* tag :: A four-byte identification tag. */ + /* */ + /* data :: A pointer to the parameter data. */ + /* */ + /* <Note> */ + /* The ID and function of parameters are driver-specific. See the */ + /* various FT_PARAM_TAG_XXX flags for more information. */ + /* */ + typedef struct FT_Parameter_ + { + FT_ULong tag; + FT_Pointer data; + + } FT_Parameter; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Open_Args */ + /* */ + /* <Description> */ + /* A structure used to indicate how to open a new font file or */ + /* stream. A pointer to such a structure can be used as a parameter */ + /* for the functions @FT_Open_Face and @FT_Attach_Stream. */ + /* */ + /* <Fields> */ + /* flags :: A set of bit flags indicating how to use the */ + /* structure. */ + /* */ + /* memory_base :: The first byte of the file in memory. */ + /* */ + /* memory_size :: The size in bytes of the file in memory. */ + /* */ + /* pathname :: A pointer to an 8-bit file pathname. */ + /* */ + /* stream :: A handle to a source stream object. */ + /* */ + /* driver :: This field is exclusively used by @FT_Open_Face; */ + /* it simply specifies the font driver to use to open */ + /* the face. If set to~0, FreeType tries to load the */ + /* face with each one of the drivers in its list. */ + /* */ + /* num_params :: The number of extra parameters. */ + /* */ + /* params :: Extra parameters passed to the font driver when */ + /* opening a new face. */ + /* */ + /* <Note> */ + /* The stream type is determined by the contents of `flags' that */ + /* are tested in the following order by @FT_Open_Face: */ + /* */ + /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ + /* memory file of `memory_size' bytes, located at `memory_address'. */ + /* The data are are not copied, and the client is responsible for */ + /* releasing and destroying them _after_ the corresponding call to */ + /* @FT_Done_Face. */ + /* */ + /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ + /* custom input stream `stream' is used. */ + /* */ + /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ + /* is a normal file and use `pathname' to open it. */ + /* */ + /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ + /* open the file with the driver whose handler is in `driver'. */ + /* */ + /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ + /* `num_params' and `params' is used. They are ignored otherwise. */ + /* */ + /* Ideally, both the `pathname' and `params' fields should be tagged */ + /* as `const'; this is missing for API backwards compatibility. In */ + /* other words, applications should treat them as read-only. */ + /* */ + typedef struct FT_Open_Args_ + { + FT_UInt flags; + const FT_Byte* memory_base; + FT_Long memory_size; + FT_String* pathname; + FT_Stream stream; + FT_Module driver; + FT_Int num_params; + FT_Parameter* params; + + } FT_Open_Args; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face */ + /* */ + /* <Description> */ + /* This function calls @FT_Open_Face to open a font by its pathname. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* pathname :: A path to the font file. */ + /* */ + /* face_index :: See @FT_Open_Face for a detailed description of this */ + /* parameter. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ + /* with its slot and sizes). */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face( FT_Library library, + const char* filepathname, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Memory_Face */ + /* */ + /* <Description> */ + /* This function calls @FT_Open_Face to open a font that has been */ + /* loaded into memory. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* file_base :: A pointer to the beginning of the font data. */ + /* */ + /* file_size :: The size of the memory chunk used by the font data. */ + /* */ + /* face_index :: See @FT_Open_Face for a detailed description of this */ + /* parameter. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You must not deallocate the memory before calling @FT_Done_Face. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Memory_Face( FT_Library library, + const FT_Byte* file_base, + FT_Long file_size, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Open_Face */ + /* */ + /* <Description> */ + /* Create a face object from a given resource described by */ + /* @FT_Open_Args. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* args :: A pointer to an `FT_Open_Args' structure that must */ + /* be filled by the caller. */ + /* */ + /* face_index :: This field holds two different values. Bits 0-15 */ + /* are the index of the face in the font file (starting */ + /* with value~0). Set it to~0 if there is only one */ + /* face in the font file. */ + /* */ + /* Bits 16-30 are relevant to GX variation fonts only, */ + /* specifying the named instance index for the current */ + /* face index (starting with value~1; value~0 makes */ + /* FreeType ignore named instances). For non-GX fonts, */ + /* bits 16-30 are ignored. Assuming that you want to */ + /* access the third named instance in face~4, */ + /* `face_index' should be set to 0x00030004. If you */ + /* want to access face~4 without GX variation handling, */ + /* simply set `face_index' to value~4. */ + /* */ + /* FT_Open_Face and its siblings can be used to quickly */ + /* check whether the font format of a given font */ + /* resource is supported by FreeType. In general, if */ + /* the `face_index' argument is negative, the */ + /* function's return value is~0 if the font format is */ + /* recognized, or non-zero otherwise. The function */ + /* allocates a more or less empty face handle in */ + /* `*aface' (if `aface' isn't NULL); the only two */ + /* useful fields in this special case are */ + /* `face->num_faces' and `face->style_flags'. For any */ + /* negative value of `face_index', `face->num_faces' */ + /* gives the number of faces within the font file. For */ + /* the negative value `-(N+1)' (with `N' a 16-bit */ + /* value), bits 16-30 in `face->style_flags' give the */ + /* number of named instances in face `N' if we have a */ + /* GX variation font (or zero otherwise). After */ + /* examination, the returned @FT_Face structure should */ + /* be deallocated with a call to @FT_Done_Face. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Unlike FreeType 1.x, this function automatically creates a glyph */ + /* slot for the face object that can be accessed directly through */ + /* `face->glyph'. */ + /* */ + /* Each new face object created with this function also owns a */ + /* default @FT_Size object, accessible as `face->size'. */ + /* */ + /* One @FT_Library instance can have multiple face objects, this is, */ + /* @FT_Open_Face and its siblings can be called multiple times using */ + /* the same `library' argument. */ + /* */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Face. */ + /* */ + /* To loop over all faces, use code similar to the following snippet */ + /* (omitting the error handling). */ + /* */ + /* { */ + /* ... */ + /* FT_Face face; */ + /* FT_Long i, num_faces; */ + /* */ + /* */ + /* error = FT_Open_Face( library, args, -1, &face ); */ + /* if ( error ) { ... } */ + /* */ + /* num_faces = face->num_faces; */ + /* FT_Done_Face( face ); */ + /* */ + /* for ( i = 0; i < num_faces; i++ ) */ + /* { */ + /* ... */ + /* error = FT_Open_Face( library, args, i, &face ); */ + /* ... */ + /* FT_Done_Face( face ); */ + /* ... */ + /* } */ + /* } */ + /* */ + /* To loop over all valid values for `face_index', use something */ + /* similar to the following snippet, again without error handling. */ + /* The code accesses all faces immediately (thus only a single call */ + /* of `FT_Open_Face' within the do-loop), with and without named */ + /* instances. */ + /* */ + /* { */ + /* ... */ + /* FT_Face face; */ + /* */ + /* FT_Long num_faces = 0; */ + /* FT_Long num_instances = 0; */ + /* */ + /* FT_Long face_idx = 0; */ + /* FT_Long instance_idx = 0; */ + /* */ + /* */ + /* do */ + /* { */ + /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ + /* */ + /* */ + /* error = FT_Open_Face( library, args, id, &face ); */ + /* if ( error ) { ... } */ + /* */ + /* num_faces = face->num_faces; */ + /* num_instances = face->style_flags >> 16; */ + /* */ + /* ... */ + /* */ + /* FT_Done_Face( face ); */ + /* */ + /* if ( instance_idx < num_instances ) */ + /* instance_idx++; */ + /* else */ + /* { */ + /* face_idx++; */ + /* instance_idx = 0; */ + /* } */ + /* */ + /* } while ( face_idx < num_faces ) */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_Open_Face( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Attach_File */ + /* */ + /* <Description> */ + /* This function calls @FT_Attach_Stream to attach a file. */ + /* */ + /* <InOut> */ + /* face :: The target face object. */ + /* */ + /* <Input> */ + /* filepathname :: The pathname. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Attach_File( FT_Face face, + const char* filepathname ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Attach_Stream */ + /* */ + /* <Description> */ + /* `Attach' data to a face object. Normally, this is used to read */ + /* additional information for the face object. For example, you can */ + /* attach an AFM file that comes with a Type~1 font to get the */ + /* kerning values and other metrics. */ + /* */ + /* <InOut> */ + /* face :: The target face object. */ + /* */ + /* <Input> */ + /* parameters :: A pointer to @FT_Open_Args that must be filled by */ + /* the caller. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The meaning of the `attach' (i.e., what really happens when the */ + /* new file is read) is not fixed by FreeType itself. It really */ + /* depends on the font format (and thus the font driver). */ + /* */ + /* Client applications are expected to know what they are doing */ + /* when invoking this function. Most drivers simply do not implement */ + /* file attachments. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Attach_Stream( FT_Face face, + FT_Open_Args* parameters ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Reference_Face */ + /* */ + /* <Description> */ + /* A counter gets initialized to~1 at the time an @FT_Face structure */ + /* is created. This function increments the counter. @FT_Done_Face */ + /* then only destroys a face if the counter is~1, otherwise it simply */ + /* decrements the counter. */ + /* */ + /* This function helps in managing life-cycles of structures that */ + /* reference @FT_Face objects. */ + /* */ + /* <Input> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.4.2 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Reference_Face( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Face */ + /* */ + /* <Description> */ + /* Discard a given face object, as well as all of its child slots and */ + /* sizes. */ + /* */ + /* <Input> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Face. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Face( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Select_Size */ + /* */ + /* <Description> */ + /* Select a bitmap strike. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* strike_index :: The index of the bitmap strike in the */ + /* `available_sizes' field of @FT_FaceRec structure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Select_Size( FT_Face face, + FT_Int strike_index ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Size_Request_Type */ + /* */ + /* <Description> */ + /* An enumeration type that lists the supported size request types. */ + /* */ + /* <Values> */ + /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ + /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ + /* used to determine both scaling values. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ + /* The real dimension. The sum of the the `ascender' and (minus */ + /* of) the `descender' fields of @FT_FaceRec are used to determine */ + /* both scaling values. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_BBOX :: */ + /* The font bounding box. The width and height of the `bbox' field */ + /* of @FT_FaceRec are used to determine the horizontal and vertical */ + /* scaling value, respectively. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_CELL :: */ + /* The `max_advance_width' field of @FT_FaceRec is used to */ + /* determine the horizontal scaling value; the vertical scaling */ + /* value is determined the same way as */ + /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ + /* values are set to the smaller one. This type is useful if you */ + /* want to specify the font size for, say, a window of a given */ + /* dimension and 80x24 cells. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_SCALES :: */ + /* Specify the scaling values directly. */ + /* */ + /* <Note> */ + /* The above descriptions only apply to scalable formats. For bitmap */ + /* formats, the behaviour is up to the driver. */ + /* */ + /* See the note section of @FT_Size_Metrics if you wonder how size */ + /* requesting relates to scaling values. */ + /* */ + typedef enum FT_Size_Request_Type_ + { + FT_SIZE_REQUEST_TYPE_NOMINAL, + FT_SIZE_REQUEST_TYPE_REAL_DIM, + FT_SIZE_REQUEST_TYPE_BBOX, + FT_SIZE_REQUEST_TYPE_CELL, + FT_SIZE_REQUEST_TYPE_SCALES, + + FT_SIZE_REQUEST_TYPE_MAX + + } FT_Size_Request_Type; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_RequestRec */ + /* */ + /* <Description> */ + /* A structure used to model a size request. */ + /* */ + /* <Fields> */ + /* type :: See @FT_Size_Request_Type. */ + /* */ + /* width :: The desired width. */ + /* */ + /* height :: The desired height. */ + /* */ + /* horiResolution :: The horizontal resolution. If set to zero, */ + /* `width' is treated as a 26.6 fractional pixel */ + /* value. */ + /* */ + /* vertResolution :: The vertical resolution. If set to zero, */ + /* `height' is treated as a 26.6 fractional pixel */ + /* value. */ + /* */ + /* <Note> */ + /* If `width' is zero, then the horizontal scaling value is set equal */ + /* to the vertical scaling value, and vice versa. */ + /* */ + typedef struct FT_Size_RequestRec_ + { + FT_Size_Request_Type type; + FT_Long width; + FT_Long height; + FT_UInt horiResolution; + FT_UInt vertResolution; + + } FT_Size_RequestRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_Request */ + /* */ + /* <Description> */ + /* A handle to a size request structure. */ + /* */ + typedef struct FT_Size_RequestRec_ *FT_Size_Request; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Request_Size */ + /* */ + /* <Description> */ + /* Resize the scale of the active @FT_Size object in a face. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* req :: A pointer to a @FT_Size_RequestRec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Although drivers may select the bitmap strike matching the */ + /* request, you should not rely on this if you intend to select a */ + /* particular bitmap strike. Use @FT_Select_Size instead in that */ + /* case. */ + /* */ + /* The relation between the requested size and the resulting glyph */ + /* size is dependent entirely on how the size is defined in the */ + /* source face. The font designer chooses the final size of each */ + /* glyph relative to this size. For more information refer to */ + /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Request_Size( FT_Face face, + FT_Size_Request req ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Char_Size */ + /* */ + /* <Description> */ + /* This function calls @FT_Request_Size to request the nominal size */ + /* (in points). */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* char_width :: The nominal width, in 26.6 fractional points. */ + /* */ + /* char_height :: The nominal height, in 26.6 fractional points. */ + /* */ + /* horz_resolution :: The horizontal resolution in dpi. */ + /* */ + /* vert_resolution :: The vertical resolution in dpi. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If either the character width or height is zero, it is set equal */ + /* to the other value. */ + /* */ + /* If either the horizontal or vertical resolution is zero, it is set */ + /* equal to the other value. */ + /* */ + /* A character width or height smaller than 1pt is set to 1pt; if */ + /* both resolution values are zero, they are set to 72dpi. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Char_Size( FT_Face face, + FT_F26Dot6 char_width, + FT_F26Dot6 char_height, + FT_UInt horz_resolution, + FT_UInt vert_resolution ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Pixel_Sizes */ + /* */ + /* <Description> */ + /* This function calls @FT_Request_Size to request the nominal size */ + /* (in pixels). */ + /* */ + /* <InOut> */ + /* face :: A handle to the target face object. */ + /* */ + /* <Input> */ + /* pixel_width :: The nominal width, in pixels. */ + /* */ + /* pixel_height :: The nominal height, in pixels. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You should not rely on the resulting glyphs matching, or being */ + /* constrained, to this pixel size. Refer to @FT_Request_Size to */ + /* understand how requested sizes relate to actual sizes. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Pixel_Sizes( FT_Face face, + FT_UInt pixel_width, + FT_UInt pixel_height ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Load_Glyph */ + /* */ + /* <Description> */ + /* A function used to load a single glyph into the glyph slot of a */ + /* face object. */ + /* */ + /* <InOut> */ + /* face :: A handle to the target face object where the glyph */ + /* is loaded. */ + /* */ + /* <Input> */ + /* glyph_index :: The index of the glyph in the font file. For */ + /* CID-keyed fonts (either in PS or in CFF format) */ + /* this argument specifies the CID value. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* @FT_LOAD_XXX constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The loaded glyph may be transformed. See @FT_Set_Transform for */ + /* the details. */ + /* */ + /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ + /* returned for invalid CID values (this is, for CID values that */ + /* don't have a corresponding glyph in the font). See the discussion */ + /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Load_Char */ + /* */ + /* <Description> */ + /* A function used to load a single glyph into the glyph slot of a */ + /* face object, according to its character code. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object where the glyph */ + /* is loaded. */ + /* */ + /* <Input> */ + /* char_code :: The glyph's character code, according to the */ + /* current charmap used in the face. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* @FT_LOAD_XXX constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Load_Char( FT_Face face, + FT_ULong char_code, + FT_Int32 load_flags ); + + + /************************************************************************* + * + * @enum: + * FT_LOAD_XXX + * + * @description: + * A list of bit field constants used with @FT_Load_Glyph to indicate + * what kind of operations to perform during glyph loading. + * + * @values: + * FT_LOAD_DEFAULT :: + * Corresponding to~0, this value is used as the default glyph load + * operation. In this case, the following happens: + * + * 1. FreeType looks for a bitmap for the glyph corresponding to the + * face's current size. If one is found, the function returns. + * The bitmap data can be accessed from the glyph slot (see note + * below). + * + * 2. If no embedded bitmap is searched or found, FreeType looks for a + * scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then `hinted' to the pixel grid + * in order to optimize it. The outline data can be accessed from + * the glyph slot (see note below). + * + * Note that by default, the glyph loader doesn't render outlines into + * bitmaps. The following flags are used to modify this default + * behaviour to more specific and useful cases. + * + * FT_LOAD_NO_SCALE :: + * Don't scale the loaded outline glyph but keep it in font units. + * + * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and + * unsets @FT_LOAD_RENDER. + * + * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using + * FT_LOAD_NO_SCALE usually yields meaningless outlines because the + * subglyphs must be scaled and positioned with hinting instructions. + * This can be solved by loading the font without FT_LOAD_NO_SCALE and + * setting the character size to `font->units_per_EM'. + * + * FT_LOAD_NO_HINTING :: + * Disable hinting. This generally generates `blurrier' bitmap glyphs + * when the glyph are rendered in any of the anti-aliased modes. See + * also the note below. + * + * This flag is implied by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_RENDER :: + * Call @FT_Render_Glyph after the glyph is loaded. By default, the + * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be + * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. + * + * This flag is unset by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_NO_BITMAP :: + * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this + * flag. + * + * @FT_LOAD_NO_SCALE always sets this flag. + * + * FT_LOAD_VERTICAL_LAYOUT :: + * Load the glyph for vertical text layout. In particular, the + * `advance' value in the @FT_GlyphSlotRec structure is set to the + * `vertAdvance' value of the `metrics' field. + * + * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use + * this flag currently. Reason is that in this case vertical metrics + * get synthesized, and those values are not always consistent across + * various font formats. + * + * FT_LOAD_FORCE_AUTOHINT :: + * Indicates that the auto-hinter is preferred over the font's native + * hinter. See also the note below. + * + * FT_LOAD_PEDANTIC :: + * Indicates that the font driver should perform pedantic verifications + * during glyph loading. This is mostly used to detect broken glyphs + * in fonts. By default, FreeType tries to handle broken fonts also. + * + * In particular, errors from the TrueType bytecode engine are not + * passed to the application if this flag is not set; this might + * result in partially hinted or distorted glyphs in case a glyph's + * bytecode is buggy. + * + * FT_LOAD_NO_RECURSE :: + * Indicate that the font driver should not load composite glyphs + * recursively. Instead, it should set the `num_subglyph' and + * `subglyphs' values of the glyph slot accordingly, and set + * `glyph->format' to @FT_GLYPH_FORMAT_COMPOSITE. The description of + * subglyphs can then be accessed with @FT_Get_SubGlyph_Info. + * + * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. + * + * FT_LOAD_IGNORE_TRANSFORM :: + * Indicates that the transform matrix set by @FT_Set_Transform should + * be ignored. + * + * FT_LOAD_MONOCHROME :: + * This flag is used with @FT_LOAD_RENDER to indicate that you want to + * render an outline glyph to a 1-bit monochrome bitmap glyph, with + * 8~pixels packed into each byte of the bitmap data. + * + * Note that this has no effect on the hinting algorithm used. You + * should rather use @FT_LOAD_TARGET_MONO so that the + * monochrome-optimized hinting algorithm is used. + * + * FT_LOAD_LINEAR_DESIGN :: + * Indicates that the `linearHoriAdvance' and `linearVertAdvance' + * fields of @FT_GlyphSlotRec should be kept in font units. See + * @FT_GlyphSlotRec for details. + * + * FT_LOAD_NO_AUTOHINT :: + * Disable auto-hinter. See also the note below. + * + * FT_LOAD_COLOR :: + * This flag is used to request loading of color embedded-bitmap + * images. The resulting color bitmaps, if available, will have the + * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color + * bitmaps are found, they will be converted to 256-level gray + * bitmaps transparently. Those bitmaps will be in the + * @FT_PIXEL_MODE_GRAY format. + * + * FT_LOAD_COMPUTE_METRICS :: + * This flag sets computing glyph metrics without the use of bundled + * metrics tables (for example, the `hdmx' table in TrueType fonts). + * Well-behaving fonts have optimized bundled metrics and these should + * be used. This flag is mainly used by font validating or font + * editing applications, which need to ignore, verify, or edit those + * tables. + * + * Currently, this flag is only implemented for TrueType fonts. + * + * FT_LOAD_CROP_BITMAP :: + * Ignored. Deprecated. + * + * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: + * Ignored. Deprecated. + * + * @note: + * By default, hinting is enabled and the font's native hinter (see + * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can + * disable hinting by setting @FT_LOAD_NO_HINTING or change the + * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be + * used at all. + * + * See the description of @FT_FACE_FLAG_TRICKY for a special exception + * (affecting only a handful of Asian fonts). + * + * Besides deciding which hinter to use, you can also decide which + * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. + * + * Note that the auto-hinter needs a valid Unicode cmap (either a native + * one or synthesized by FreeType) for producing correct results. If a + * font provides an incorrect mapping (for example, assigning the + * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a + * mathematical integral sign), the auto-hinter might produce useless + * results. + * + */ +#define FT_LOAD_DEFAULT 0x0 +#define FT_LOAD_NO_SCALE ( 1L << 0 ) +#define FT_LOAD_NO_HINTING ( 1L << 1 ) +#define FT_LOAD_RENDER ( 1L << 2 ) +#define FT_LOAD_NO_BITMAP ( 1L << 3 ) +#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) +#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) +#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) +#define FT_LOAD_PEDANTIC ( 1L << 7 ) +#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) +#define FT_LOAD_NO_RECURSE ( 1L << 10 ) +#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) +#define FT_LOAD_MONOCHROME ( 1L << 12 ) +#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) +#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) + /* Bits 16..19 are used by `FT_LOAD_TARGET_' */ +#define FT_LOAD_COLOR ( 1L << 20 ) +#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) + + /* */ + + /* used internally only by certain font drivers! */ +#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) +#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) + + + /************************************************************************** + * + * @enum: + * FT_LOAD_TARGET_XXX + * + * @description: + * A list of values that are used to select a specific hinting algorithm + * to use by the hinter. You should OR one of these values to your + * `load_flags' when calling @FT_Load_Glyph. + * + * Note that font's native hinters may ignore the hinting algorithm you + * have specified (e.g., the TrueType bytecode interpreter). You can set + * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. + * + * @values: + * FT_LOAD_TARGET_NORMAL :: + * This corresponds to the default hinting algorithm, optimized for + * standard gray-level rendering. For monochrome output, use + * @FT_LOAD_TARGET_MONO instead. + * + * FT_LOAD_TARGET_LIGHT :: + * A lighter hinting algorithm for gray-level modes. Many generated + * glyphs are fuzzier but better resemble their original shape. This + * is achieved by snapping glyphs to the pixel grid only vertically + * (Y-axis), as is done by Microsoft's ClearType and Adobe's + * proprietary font renderer. This preserves inter-glyph spacing in + * horizontal text. The snapping is done either by the native font + * driver if the driver itself and the font support it or by the + * auto-hinter. + * + * FT_LOAD_TARGET_MONO :: + * Strong hinting algorithm that should only be used for monochrome + * output. The result is probably unpleasant if the glyph is rendered + * in non-monochrome modes. + * + * FT_LOAD_TARGET_LCD :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally + * decimated LCD displays. + * + * FT_LOAD_TARGET_LCD_V :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically + * decimated LCD displays. + * + * @note: + * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your + * `load_flags'. They can't be ORed. + * + * If @FT_LOAD_RENDER is also set, the glyph is rendered in the + * corresponding mode (i.e., the mode that matches the used algorithm + * best). An exeption is FT_LOAD_TARGET_MONO since it implies + * @FT_LOAD_MONOCHROME. + * + * You can use a hinting algorithm that doesn't correspond to the same + * rendering mode. As an example, it is possible to use the `light' + * hinting algorithm and have the results rendered in horizontal LCD + * pixel mode, with code like + * + * { + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); + * + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * } + * + */ +#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) + +#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) +#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) +#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) +#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) +#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) + + + /************************************************************************** + * + * @macro: + * FT_LOAD_TARGET_MODE + * + * @description: + * Return the @FT_Render_Mode corresponding to a given + * @FT_LOAD_TARGET_XXX value. + * + */ +#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Transform */ + /* */ + /* <Description> */ + /* A function used to set the transformation that is applied to glyph */ + /* images when they are loaded into a glyph slot through */ + /* @FT_Load_Glyph. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */ + /* the identity matrix. */ + /* delta :: A pointer to the translation vector. Use~0 for the null */ + /* vector. */ + /* */ + /* <Note> */ + /* The transformation is only applied to scalable image formats after */ + /* the glyph has been loaded. It means that hinting is unaltered by */ + /* the transformation and is performed on the character size given in */ + /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ + /* */ + /* Note that this also transforms the `face.glyph.advance' field, but */ + /* *not* the values in `face.glyph.metrics'. */ + /* */ + FT_EXPORT( void ) + FT_Set_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Render_Mode */ + /* */ + /* <Description> */ + /* An enumeration type that lists the render modes supported by */ + /* FreeType~2. Each mode corresponds to a specific type of scanline */ + /* conversion performed on the outline. */ + /* */ + /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ + /* field in the @FT_GlyphSlotRec structure gives the format of the */ + /* returned bitmap. */ + /* */ + /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ + /* indicating pixel coverage. Use linear alpha blending and gamma */ + /* correction to correctly render non-monochrome glyph bitmaps onto a */ + /* surface; see @FT_Render_Glyph. */ + /* */ + /* <Values> */ + /* FT_RENDER_MODE_NORMAL :: */ + /* This is the default render mode; it corresponds to 8-bit */ + /* anti-aliased bitmaps. */ + /* */ + /* FT_RENDER_MODE_LIGHT :: */ + /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ + /* defined as a separate value because render modes are also used */ + /* indirectly to define hinting algorithm selectors. See */ + /* @FT_LOAD_TARGET_XXX for details. */ + /* */ + /* FT_RENDER_MODE_MONO :: */ + /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ + /* opacity). */ + /* */ + /* FT_RENDER_MODE_LCD :: */ + /* This mode corresponds to horizontal RGB and BGR sub-pixel */ + /* displays like LCD screens. It produces 8-bit bitmaps that are */ + /* 3~times the width of the original glyph outline in pixels, and */ + /* which use the @FT_PIXEL_MODE_LCD mode. */ + /* */ + /* FT_RENDER_MODE_LCD_V :: */ + /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ + /* (like PDA screens, rotated LCD displays, etc.). It produces */ + /* 8-bit bitmaps that are 3~times the height of the original */ + /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ + /* */ + /* <Note> */ + /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */ + /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */ + /* (not active in the default builds). It is up to the caller to */ + /* either call @FT_Library_SetLcdFilter (if available) or do the */ + /* filtering itself. */ + /* */ + /* The selected render mode only affects vector glyphs of a font. */ + /* Embedded bitmaps often have a different pixel mode like */ + /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ + /* them into 8-bit pixmaps. */ + /* */ + typedef enum FT_Render_Mode_ + { + FT_RENDER_MODE_NORMAL = 0, + FT_RENDER_MODE_LIGHT, + FT_RENDER_MODE_MONO, + FT_RENDER_MODE_LCD, + FT_RENDER_MODE_LCD_V, + + FT_RENDER_MODE_MAX + + } FT_Render_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Render_Mode' values instead */ +#define ft_render_mode_normal FT_RENDER_MODE_NORMAL +#define ft_render_mode_mono FT_RENDER_MODE_MONO + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Render_Glyph */ + /* */ + /* <Description> */ + /* Convert a given glyph image to a bitmap. It does so by inspecting */ + /* the glyph image format, finding the relevant renderer, and */ + /* invoking it. */ + /* */ + /* <InOut> */ + /* slot :: A handle to the glyph slot containing the image to */ + /* convert. */ + /* */ + /* <Input> */ + /* render_mode :: This is the render mode used to render the glyph */ + /* image into a bitmap. See @FT_Render_Mode for a */ + /* list of possible values. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* To get meaningful results, font scaling values must be set with */ + /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ + /* */ + /* When FreeType outputs a bitmap of a glyph, it really outputs an */ + /* alpha coverage map. If a pixel is completely covered by a */ + /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ + /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ + /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ + /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ + /* middle shade of grey). 0% covered means 0% black (100% bright or */ + /* white). */ + /* */ + /* On high-DPI screens like on smartphones and tablets, the pixels */ + /* are so small that their chance of being completely covered and */ + /* therefore completely black are fairly good. On the low-DPI */ + /* screens, however, the situation is different. The pixels are too */ + /* large for most of the details of a glyph and shades of gray are */ + /* the norm rather than the exception. */ + /* */ + /* This is relevant because all our screens have a second problem: */ + /* they are not linear. 1~+~1 is not~2. Twice the value does not */ + /* result in twice the brightness. When a pixel is only 50% covered, */ + /* the coverage map says 50% black, and this translates to a pixel */ + /* value of 128 when you use 8~bits per channel (0-255). However, */ + /* this does not translate to 50% brightness for that pixel on our */ + /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ + /* dwell longer in the darks and only a pixel value of about 186 */ + /* results in 50% brightness – 128 ends up too dark on both bright */ + /* and dark backgrounds. The net result is that dark text looks */ + /* burnt-out, pixely and blotchy on bright background, bright text */ + /* too frail on dark backgrounds, and colored text on colored */ + /* background (for example, red on green) seems to have dark halos or */ + /* `dirt' around it. The situation is especially ugly for diagonal */ + /* stems like in `w' glyph shapes where the quality of FreeType's */ + /* anti-aliasing depends on the correct display of grays. On */ + /* high-DPI screens where smaller, fully black pixels reign supreme, */ + /* this doesn't matter, but on our low-DPI screens with all the gray */ + /* shades, it does. 0% and 100% brightness are the same things in */ + /* linear and non-linear space, just all the shades in-between */ + /* aren't. */ + /* */ + /* The blending function for placing text over a background is */ + /* */ + /* { */ + /* dst = alpha * src + (1 - alpha) * dst , */ + /* } */ + /* */ + /* which is known as the OVER operator. */ + /* */ + /* To correctly composite an antialiased pixel of a glyph onto a */ + /* surface, */ + /* */ + /* 1. take the foreground and background colors (e.g., in sRGB space) */ + /* and apply gamma to get them in a linear space, */ + /* */ + /* 2. use OVER to blend the two linear colors using the glyph pixel */ + /* as the alpha value (remember, the glyph bitmap is an alpha */ + /* coverage bitmap), and */ + /* */ + /* 3. apply inverse gamma to the blended pixel and write it back to */ + /* the image. */ + /* */ + /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ + /* for step~3 gives good results across a wide range of displays with */ + /* an sRGB gamma curve or a similar one. */ + /* */ + /* This process can cost performance. There is an approximation that */ + /* does not need to know about the background color; see */ + /* https://bel.fi/alankila/lcd/ and */ + /* https://bel.fi/alankila/lcd/alpcor.html for details. */ + /* */ + /* *ATTENTION*: Linear blending is even more important when dealing */ + /* with subpixel-rendered glyphs to prevent color-fringing! A */ + /* subpixel-rendered glyph must first be filtered with a filter that */ + /* gives equal weight to the three color primaries and does not */ + /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ + /* only difference to gray linear blending is that subpixel-rendered */ + /* linear blending is done 3~times per pixel: red foreground subpixel */ + /* to red background subpixel and so on for green and blue. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Render_Glyph( FT_GlyphSlot slot, + FT_Render_Mode render_mode ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Kerning_Mode */ + /* */ + /* <Description> */ + /* An enumeration used to specify which kerning values to return in */ + /* @FT_Get_Kerning. */ + /* */ + /* <Values> */ + /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ + /* pixels (value is~0). Whether they are */ + /* scaled depends on @FT_LOAD_NO_SCALE. */ + /* */ + /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ + /* 26.6 fractional pixels. Whether they are */ + /* scaled depends on @FT_LOAD_NO_SCALE. */ + /* */ + /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ + /* units. */ + /* */ + /* <Note> */ + /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ + /* FreeType heuristically scale down kerning distances at small ppem */ + /* values so that they don't become too big. */ + /* */ + typedef enum FT_Kerning_Mode_ + { + FT_KERNING_DEFAULT = 0, + FT_KERNING_UNFITTED, + FT_KERNING_UNSCALED + + } FT_Kerning_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Kerning_Mode' values instead */ +#define ft_kerning_default FT_KERNING_DEFAULT +#define ft_kerning_unfitted FT_KERNING_UNFITTED +#define ft_kerning_unscaled FT_KERNING_UNSCALED + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Kerning */ + /* */ + /* <Description> */ + /* Return the kerning vector between two glyphs of a same face. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* left_glyph :: The index of the left glyph in the kern pair. */ + /* */ + /* right_glyph :: The index of the right glyph in the kern pair. */ + /* */ + /* kern_mode :: See @FT_Kerning_Mode for more information. */ + /* Determines the scale and dimension of the returned */ + /* kerning vector. */ + /* */ + /* <Output> */ + /* akerning :: The kerning vector. This is either in font units, */ + /* fractional pixels (26.6 format), or pixels for */ + /* scalable formats, and in pixels for fixed-sizes */ + /* formats. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Only horizontal layouts (left-to-right & right-to-left) are */ + /* supported by this method. Other layouts, or more sophisticated */ + /* kernings, are out of the scope of this API function -- they can be */ + /* implemented through format-specific interfaces. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Kerning( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_UInt kern_mode, + FT_Vector *akerning ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Track_Kerning */ + /* */ + /* <Description> */ + /* Return the track kerning for a given face object at a given size. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* point_size :: The point size in 16.16 fractional points. */ + /* */ + /* degree :: The degree of tightness. Increasingly negative */ + /* values represent tighter track kerning, while */ + /* increasingly positive values represent looser track */ + /* kerning. Value zero means no track kerning. */ + /* */ + /* <Output> */ + /* akerning :: The kerning in 16.16 fractional points, to be */ + /* uniformly applied between all glyphs. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Currently, only the Type~1 font driver supports track kerning, */ + /* using data from AFM files (if attached with @FT_Attach_File or */ + /* @FT_Attach_Stream). */ + /* */ + /* Only very few AFM files come with track kerning data; please refer */ + /* to the Adobe's AFM specification for more details. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Track_Kerning( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Glyph_Name */ + /* */ + /* <Description> */ + /* Retrieve the ASCII name of a given glyph in a face. This only */ + /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* glyph_index :: The glyph index. */ + /* */ + /* buffer_max :: The maximum number of bytes available in the */ + /* buffer. */ + /* */ + /* <Output> */ + /* buffer :: A pointer to a target buffer where the name is */ + /* copied to. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* An error is returned if the face doesn't provide glyph names or if */ + /* the glyph index is invalid. In all cases of failure, the first */ + /* byte of `buffer' is set to~0 to indicate an empty name. */ + /* */ + /* The glyph name is truncated to fit within the buffer if it is too */ + /* long. The returned string is always zero-terminated. */ + /* */ + /* Be aware that FreeType reorders glyph indices internally so that */ + /* glyph index~0 always corresponds to the `missing glyph' (called */ + /* `.notdef'). */ + /* */ + /* This function always returns an error if the config macro */ + /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoptions.h'. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph_Name( FT_Face face, + FT_UInt glyph_index, + FT_Pointer buffer, + FT_UInt buffer_max ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Postscript_Name */ + /* */ + /* <Description> */ + /* Retrieve the ASCII PostScript name of a given face, if available. */ + /* This only works with PostScript and TrueType fonts. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Return> */ + /* A pointer to the face's PostScript name. NULL if unavailable. */ + /* */ + /* <Note> */ + /* The returned pointer is owned by the face and is destroyed with */ + /* it. */ + /* */ + FT_EXPORT( const char* ) + FT_Get_Postscript_Name( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Select_Charmap */ + /* */ + /* <Description> */ + /* Select a given charmap by its encoding tag (as listed in */ + /* `freetype.h'). */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* encoding :: A handle to the selected encoding. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function returns an error if no charmap in the face */ + /* corresponds to the encoding queried here. */ + /* */ + /* Because many fonts contain more than a single cmap for Unicode */ + /* encoding, this function has some special code to select the one */ + /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ + /* preferred to a UCS-2 cmap). It is thus preferable to */ + /* @FT_Set_Charmap in this case. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Select_Charmap( FT_Face face, + FT_Encoding encoding ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Charmap */ + /* */ + /* <Description> */ + /* Select a given charmap for character code to glyph index mapping. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* charmap :: A handle to the selected charmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function returns an error if the charmap is not part of */ + /* the face (i.e., if it is not listed in the `face->charmaps' */ + /* table). */ + /* */ + /* It also fails if a type~14 charmap is selected. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ); + + + /************************************************************************* + * + * @function: + * FT_Get_Charmap_Index + * + * @description: + * Retrieve index of a given charmap. + * + * @input: + * charmap :: + * A handle to a charmap. + * + * @return: + * The index into the array of character maps within the face to which + * `charmap' belongs. If an error occurs, -1 is returned. + * + */ + FT_EXPORT( FT_Int ) + FT_Get_Charmap_Index( FT_CharMap charmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Char_Index */ + /* */ + /* <Description> */ + /* Return the glyph index of a given character code. This function */ + /* uses a charmap object to do the mapping. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* charcode :: The character code. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means `undefined character code'. */ + /* */ + /* <Note> */ + /* If you use FreeType to manipulate the contents of font files */ + /* directly, be aware that the glyph index returned by this function */ + /* doesn't always correspond to the internal indices used within the */ + /* file. This is done to ensure that value~0 always corresponds to */ + /* the `missing glyph'. If the first glyph is not named `.notdef', */ + /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ + /* the glyph ID~0 position, and whatever was there will be moved to */ + /* the position `.notdef' had. For Type~1 fonts, if there is no */ + /* `.notdef' glyph at all, then one will be created at index~0 and */ + /* whatever was there will be moved to the last index -- Type~42 */ + /* fonts are considered invalid under this condition. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Char_Index( FT_Face face, + FT_ULong charcode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_First_Char */ + /* */ + /* <Description> */ + /* This function is used to return the first character code in the */ + /* current charmap of a given face. It also returns the */ + /* corresponding glyph index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Output> */ + /* agindex :: Glyph index of first character code. 0~if charmap is */ + /* empty. */ + /* */ + /* <Return> */ + /* The charmap's first character code. */ + /* */ + /* <Note> */ + /* You should use this function with @FT_Get_Next_Char to be able to */ + /* parse all character codes available in a given charmap. The code */ + /* should look like this: */ + /* */ + /* { */ + /* FT_ULong charcode; */ + /* FT_UInt gindex; */ + /* */ + /* */ + /* charcode = FT_Get_First_Char( face, &gindex ); */ + /* while ( gindex != 0 ) */ + /* { */ + /* ... do something with (charcode,gindex) pair ... */ + /* */ + /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ + /* } */ + /* } */ + /* */ + /* Be aware that character codes can have values up to 0xFFFFFFFF; */ + /* this might happen for non-Unicode or malformed cmaps. However, */ + /* even with regular Unicode encoding, so-called `last resort fonts' */ + /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ + /* normally have entries for all Unicode characters up to 0x1FFFFF, */ + /* which can cause *a lot* of iterations. */ + /* */ + /* Note that `*agindex' is set to~0 if the charmap is empty. The */ + /* result itself can be~0 in two cases: if the charmap is empty or */ + /* if the value~0 is the first valid character code. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_First_Char( FT_Face face, + FT_UInt *agindex ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Next_Char */ + /* */ + /* <Description> */ + /* This function is used to return the next character code in the */ + /* current charmap of a given face following the value `char_code', */ + /* as well as the corresponding glyph index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* char_code :: The starting character code. */ + /* */ + /* <Output> */ + /* agindex :: Glyph index of next character code. 0~if charmap */ + /* is empty. */ + /* */ + /* <Return> */ + /* The charmap's next character code. */ + /* */ + /* <Note> */ + /* You should use this function with @FT_Get_First_Char to walk */ + /* over all character codes available in a given charmap. See the */ + /* note for this function for a simple code example. */ + /* */ + /* Note that `*agindex' is set to~0 when there are no more codes in */ + /* the charmap. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_Next_Char( FT_Face face, + FT_ULong char_code, + FT_UInt *agindex ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Name_Index */ + /* */ + /* <Description> */ + /* Return the glyph index of a given glyph name. This function uses */ + /* driver specific objects to do the translation. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* glyph_name :: The glyph name. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means `undefined character code'. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Name_Index( FT_Face face, + FT_String* glyph_name ); + + + /************************************************************************* + * + * @macro: + * FT_SUBGLYPH_FLAG_XXX + * + * @description: + * A list of constants used to describe subglyphs. Please refer to the + * TrueType specification for the meaning of the various flags. + * + * @values: + * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: + * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: + * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: + * FT_SUBGLYPH_FLAG_SCALE :: + * FT_SUBGLYPH_FLAG_XY_SCALE :: + * FT_SUBGLYPH_FLAG_2X2 :: + * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: + * + */ +#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 +#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 +#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 +#define FT_SUBGLYPH_FLAG_SCALE 8 +#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 +#define FT_SUBGLYPH_FLAG_2X2 0x80 +#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 + + + /************************************************************************* + * + * @func: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is + * returned otherwise. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of the subglyph. Must be less than + * `glyph->num_subglyphs'. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be + * interpreted depending on the flags returned in `*p_flags'. See the + * TrueType specification for details. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_FSTYPE_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the `fsType' field of the OS/2 table */ + /* in a TrueType or OpenType font and the `FSType' entry in a */ + /* PostScript font. These bit flags are returned by */ + /* @FT_Get_FSType_Flags; they inform client applications of embedding */ + /* and subsetting restrictions associated with a font. */ + /* */ + /* See */ + /* http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ + /* for more details. */ + /* */ + /* <Values> */ + /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ + /* Fonts with no fsType bit set may be embedded and permanently */ + /* installed on the remote system by an application. */ + /* */ + /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ + /* Fonts that have only this bit set must not be modified, embedded */ + /* or exchanged in any manner without first obtaining permission of */ + /* the font software copyright owner. */ + /* */ + /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ + /* If this bit is set, the font may be embedded and temporarily */ + /* loaded on the remote system. Documents containing Preview & */ + /* Print fonts must be opened `read-only'; no edits can be applied */ + /* to the document. */ + /* */ + /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ + /* If this bit is set, the font may be embedded but must only be */ + /* installed temporarily on other systems. In contrast to Preview */ + /* & Print fonts, documents containing editable fonts may be opened */ + /* for reading, editing is permitted, and changes may be saved. */ + /* */ + /* FT_FSTYPE_NO_SUBSETTING :: */ + /* If this bit is set, the font may not be subsetted prior to */ + /* embedding. */ + /* */ + /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ + /* If this bit is set, only bitmaps contained in the font may be */ + /* embedded; no outline data may be embedded. If there are no */ + /* bitmaps available in the font, then the font is unembeddable. */ + /* */ + /* <Note> */ + /* The flags are ORed together, thus more than a single value can be */ + /* returned. */ + /* */ + /* While the fsType flags can indicate that a font may be embedded, a */ + /* license with the font vendor may be separately required to use the */ + /* font in this way. */ + /* */ +#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 +#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 +#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 +#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 +#define FT_FSTYPE_NO_SUBSETTING 0x0100 +#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_FSType_Flags */ + /* */ + /* <Description> */ + /* Return the fsType flags for a font. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Return> */ + /* The fsType flags, @FT_FSTYPE_XXX. */ + /* */ + /* <Note> */ + /* Use this function rather than directly reading the `fs_type' field */ + /* in the @PS_FontInfoRec structure, which is only guaranteed to */ + /* return the correct results for Type~1 fonts. */ + /* */ + /* <Since> */ + /* 2.3.8 */ + /* */ + FT_EXPORT( FT_UShort ) + FT_Get_FSType_Flags( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* glyph_variants */ + /* */ + /* <Title> */ + /* Glyph Variants */ + /* */ + /* <Abstract> */ + /* The FreeType~2 interface to Unicode Ideographic Variation */ + /* Sequences (IVS), using the SFNT cmap format~14. */ + /* */ + /* <Description> */ + /* Many CJK characters have variant forms. They are a sort of grey */ + /* area somewhere between being totally irrelevant and semantically */ + /* distinct; for this reason, the Unicode consortium decided to */ + /* introduce Ideographic Variation Sequences (IVS), consisting of a */ + /* Unicode base character and one of 240 variant selectors */ + /* (U+E0100-U+E01EF), instead of further extending the already huge */ + /* code range for CJK characters. */ + /* */ + /* An IVS is registered and unique; for further details please refer */ + /* to Unicode Technical Standard #37, the Ideographic Variation */ + /* Database: */ + /* */ + /* http://www.unicode.org/reports/tr37/ */ + /* */ + /* To date (November 2014), the character with the most variants is */ + /* U+9089, having 32 such IVS. */ + /* */ + /* Adobe and MS decided to support IVS with a new cmap subtable */ + /* (format~14). It is an odd subtable because it is not a mapping of */ + /* input code points to glyphs, but contains lists of all variants */ + /* supported by the font. */ + /* */ + /* A variant may be either `default' or `non-default'. A default */ + /* variant is the one you will get for that code point if you look it */ + /* up in the standard Unicode cmap. A non-default variant is a */ + /* different glyph. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharVariantIndex */ + /* */ + /* <Description> */ + /* Return the glyph index of a given character code as modified by */ + /* the variation selector. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character code point in Unicode. */ + /* */ + /* variantSelector :: */ + /* The Unicode code point of the variation selector. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means either `undefined character code', or */ + /* `undefined selector code', or `no variation selector cmap */ + /* subtable', or `current CharMap is not Unicode'. */ + /* */ + /* <Note> */ + /* If you use FreeType to manipulate the contents of font files */ + /* directly, be aware that the glyph index returned by this function */ + /* doesn't always correspond to the internal indices used within */ + /* the file. This is done to ensure that value~0 always corresponds */ + /* to the `missing glyph'. */ + /* */ + /* This function is only meaningful if */ + /* a) the font has a variation selector cmap sub table, */ + /* and */ + /* b) the current charmap has a Unicode encoding. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Face_GetCharVariantIndex( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharVariantIsDefault */ + /* */ + /* <Description> */ + /* Check whether this variant of this Unicode character is the one to */ + /* be found in the `cmap'. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character codepoint in Unicode. */ + /* */ + /* variantSelector :: */ + /* The Unicode codepoint of the variation selector. */ + /* */ + /* <Return> */ + /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ + /* variation selector cmap, or -1 if it is not a variant. */ + /* */ + /* <Note> */ + /* This function is only meaningful if the font has a variation */ + /* selector cmap subtable. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_Int ) + FT_Face_GetCharVariantIsDefault( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetVariantSelectors */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode variant selectors found */ + /* in the font. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* <Return> */ + /* A pointer to an array of selector code points, or NULL if there is */ + /* no valid variant selector cmap subtable. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantSelectors( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetVariantsOfChar */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode variant selectors found */ + /* for the specified character code. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character codepoint in Unicode. */ + /* */ + /* <Return> */ + /* A pointer to an array of variant selector code points that are */ + /* active for the given character, or NULL if the corresponding list */ + /* is empty. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantsOfChar( FT_Face face, + FT_ULong charcode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharsOfVariant */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode character codes found for */ + /* the specified variant selector. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* variantSelector :: */ + /* The variant selector code point in Unicode. */ + /* */ + /* <Return> */ + /* A list of all the code points that are specified by this selector */ + /* (both default and non-default codes are returned) or NULL if there */ + /* is no valid cmap or the variant selector is invalid. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetCharsOfVariant( FT_Face face, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /* <Title> */ + /* Computations */ + /* */ + /* <Abstract> */ + /* Crunching fixed numbers and vectors. */ + /* */ + /* <Description> */ + /* This section contains various functions used to perform */ + /* computations on 16.16 fixed-float numbers or 2d vectors. */ + /* */ + /* <Order> */ + /* FT_MulDiv */ + /* FT_MulFix */ + /* FT_DivFix */ + /* FT_RoundFix */ + /* FT_CeilFix */ + /* FT_FloorFix */ + /* FT_Vector_Transform */ + /* FT_Matrix_Multiply */ + /* FT_Matrix_Invert */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_MulDiv */ + /* */ + /* <Description> */ + /* A very simple function used to perform the computation `(a*b)/c' */ + /* with maximum accuracy (it uses a 64-bit intermediate integer */ + /* whenever necessary). */ + /* */ + /* This function isn't necessarily as fast as some processor specific */ + /* operations, but is at least completely portable. */ + /* */ + /* <Input> */ + /* a :: The first multiplier. */ + /* b :: The second multiplier. */ + /* c :: The divisor. */ + /* */ + /* <Return> */ + /* The result of `(a*b)/c'. This function never traps when trying to */ + /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ + /* on the signs of `a' and `b'. */ + /* */ + FT_EXPORT( FT_Long ) + FT_MulDiv( FT_Long a, + FT_Long b, + FT_Long c ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_MulFix */ + /* */ + /* <Description> */ + /* A very simple function used to perform the computation */ + /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ + /* used to multiply a given value by a 16.16 fixed-point factor. */ + /* */ + /* <Input> */ + /* a :: The first multiplier. */ + /* b :: The second multiplier. Use a 16.16 factor here whenever */ + /* possible (see note below). */ + /* */ + /* <Return> */ + /* The result of `(a*b)/0x10000'. */ + /* */ + /* <Note> */ + /* This function has been optimized for the case where the absolute */ + /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ + /* As this happens mainly when scaling from notional units to */ + /* fractional pixels in FreeType, it resulted in noticeable speed */ + /* improvements between versions 2.x and 1.x. */ + /* */ + /* As a conclusion, always try to place a 16.16 factor as the */ + /* _second_ argument of this function; this can make a great */ + /* difference. */ + /* */ + FT_EXPORT( FT_Long ) + FT_MulFix( FT_Long a, + FT_Long b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_DivFix */ + /* */ + /* <Description> */ + /* A very simple function used to perform the computation */ + /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ + /* used to divide a given value by a 16.16 fixed-point factor. */ + /* */ + /* <Input> */ + /* a :: The numerator. */ + /* b :: The denominator. Use a 16.16 factor here. */ + /* */ + /* <Return> */ + /* The result of `(a*0x10000)/b'. */ + /* */ + FT_EXPORT( FT_Long ) + FT_DivFix( FT_Long a, + FT_Long b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_RoundFix */ + /* */ + /* <Description> */ + /* A very simple function used to round a 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number to be rounded. */ + /* */ + /* <Return> */ + /* `a' rounded to nearest 16.16 fixed integer, halfway cases away */ + /* from zero. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_RoundFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_CeilFix */ + /* */ + /* <Description> */ + /* A very simple function used to compute the ceiling function of a */ + /* 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number for which the ceiling function is to be computed. */ + /* */ + /* <Return> */ + /* `a' rounded towards plus infinity. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_CeilFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_FloorFix */ + /* */ + /* <Description> */ + /* A very simple function used to compute the floor function of a */ + /* 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number for which the floor function is to be computed. */ + /* */ + /* <Return> */ + /* `a' rounded towards minus infinity. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_FloorFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Vector_Transform */ + /* */ + /* <Description> */ + /* Transform a single vector through a 2x2 matrix. */ + /* */ + /* <InOut> */ + /* vector :: The target vector to transform. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the source 2x2 matrix. */ + /* */ + /* <Note> */ + /* The result is undefined if either `vector' or `matrix' is invalid. */ + /* */ + FT_EXPORT( void ) + FT_Vector_Transform( FT_Vector* vec, + const FT_Matrix* matrix ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* version */ + /* */ + /* <Title> */ + /* FreeType Version */ + /* */ + /* <Abstract> */ + /* Functions and macros related to FreeType versions. */ + /* */ + /* <Description> */ + /* Note that those functions and macros are of limited use because */ + /* even a new release of FreeType with only documentation changes */ + /* increases the version number. */ + /* */ + /* <Order> */ + /* FT_Library_Version */ + /* */ + /* FREETYPE_MAJOR */ + /* FREETYPE_MINOR */ + /* FREETYPE_PATCH */ + /* */ + /* FT_Face_CheckTrueTypePatents */ + /* FT_Face_SetUnpatentedHinting */ + /* */ + /* FREETYPE_XXX */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @enum: + * FREETYPE_XXX + * + * @description: + * These three macros identify the FreeType source code version. + * Use @FT_Library_Version to access them at runtime. + * + * @values: + * FREETYPE_MAJOR :: The major version number. + * FREETYPE_MINOR :: The minor version number. + * FREETYPE_PATCH :: The patch level. + * + * @note: + * The version number of FreeType if built as a dynamic link library + * with the `libtool' package is _not_ controlled by these three + * macros. + * + */ +#define FREETYPE_MAJOR 2 +#define FREETYPE_MINOR 6 +#define FREETYPE_PATCH 3 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Library_Version */ + /* */ + /* <Description> */ + /* Return the version of the FreeType library being used. This is */ + /* useful when dynamically linking to the library, since one cannot */ + /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ + /* @FREETYPE_PATCH. */ + /* */ + /* <Input> */ + /* library :: A source library handle. */ + /* */ + /* <Output> */ + /* amajor :: The major version number. */ + /* */ + /* aminor :: The minor version number. */ + /* */ + /* apatch :: The patch version number. */ + /* */ + /* <Note> */ + /* The reason why this function takes a `library' argument is because */ + /* certain programs implement library initialization in a custom way */ + /* that doesn't use @FT_Init_FreeType. */ + /* */ + /* In such cases, the library version might not be available before */ + /* the library object has been created. */ + /* */ + FT_EXPORT( void ) + FT_Library_Version( FT_Library library, + FT_Int *amajor, + FT_Int *aminor, + FT_Int *apatch ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_CheckTrueTypePatents */ + /* */ + /* <Description> */ + /* Deprecated, does nothing. */ + /* */ + /* <Input> */ + /* face :: A face handle. */ + /* */ + /* <Return> */ + /* Always returns false. */ + /* */ + /* <Note> */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ + /* <Since> */ + /* 2.3.5 */ + /* */ + FT_EXPORT( FT_Bool ) + FT_Face_CheckTrueTypePatents( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_SetUnpatentedHinting */ + /* */ + /* <Description> */ + /* Deprecated, does nothing. */ + /* */ + /* <Input> */ + /* face :: A face handle. */ + /* */ + /* value :: New boolean setting. */ + /* */ + /* <Return> */ + /* Always returns false. */ + /* */ + /* <Note> */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ + /* <Since> */ + /* 2.3.5 */ + /* */ + FT_EXPORT( FT_Bool ) + FT_Face_SetUnpatentedHinting( FT_Face face, + FT_Bool value ); + + /* */ + + +FT_END_HEADER + +#endif /* FREETYPE_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftadvanc.h b/foreign/freetype2/freetype/ftadvanc.h new file mode 100644 index 0000000..023dd84 --- /dev/null +++ b/foreign/freetype2/freetype/ftadvanc.h @@ -0,0 +1,187 @@ +/***************************************************************************/ +/* */ +/* ftadvanc.h */ +/* */ +/* Quick computation of advance widths (specification only). */ +/* */ +/* Copyright 2008-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTADVANC_H_ +#define FTADVANC_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * quick_advance + * + * @title: + * Quick retrieval of advance values + * + * @abstract: + * Retrieve horizontal and vertical advance values without processing + * glyph outlines, if possible. + * + * @description: + * This section contains functions to quickly extract advance values + * without handling glyph outlines, if possible. + * + * @order: + * FT_Get_Advance + * FT_Get_Advances + * + */ + + + /*************************************************************************/ + /* */ + /* <Const> */ + /* FT_ADVANCE_FLAG_FAST_ONLY */ + /* */ + /* <Description> */ + /* A bit-flag to be OR-ed with the `flags' parameter of the */ + /* @FT_Get_Advance and @FT_Get_Advances functions. */ + /* */ + /* If set, it indicates that you want these functions to fail if the */ + /* corresponding hinting mode or font driver doesn't allow for very */ + /* quick advance computation. */ + /* */ + /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ + /* or light-hinted can have their advance width computed very */ + /* quickly. */ + /* */ + /* Normal and bytecode hinted modes that require loading, scaling, */ + /* and hinting of the glyph outline, are extremely slow by */ + /* comparison. */ + /* */ +#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Advance */ + /* */ + /* <Description> */ + /* Retrieve the advance value of a given glyph outline in an */ + /* @FT_Face. */ + /* */ + /* <Input> */ + /* face :: The source @FT_Face handle. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* load_flags :: A set of bit flags similar to those used when */ + /* calling @FT_Load_Glyph, used to determine what kind */ + /* of advances you need. */ + /* <Output> */ + /* padvance :: The advance value. If scaling is performed (based on */ + /* the value of `load_flags'), the advance value is in */ + /* 16.16 format. Otherwise, it is in font units. */ + /* */ + /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ + /* vertical advance corresponding to a vertical layout. */ + /* Otherwise, it is the horizontal advance in a */ + /* horizontal layout. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ + /* if the corresponding font backend doesn't have a quick way to */ + /* retrieve the advances. */ + /* */ + /* A scaled advance is returned in 16.16 format but isn't transformed */ + /* by the affine transformation specified by @FT_Set_Transform. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Advance( FT_Face face, + FT_UInt gindex, + FT_Int32 load_flags, + FT_Fixed *padvance ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Advances */ + /* */ + /* <Description> */ + /* Retrieve the advance values of several glyph outlines in an */ + /* @FT_Face. */ + /* */ + /* <Input> */ + /* face :: The source @FT_Face handle. */ + /* */ + /* start :: The first glyph index. */ + /* */ + /* count :: The number of advance values you want to retrieve. */ + /* */ + /* load_flags :: A set of bit flags similar to those used when */ + /* calling @FT_Load_Glyph. */ + /* */ + /* <Output> */ + /* padvance :: The advance values. This array, to be provided by the */ + /* caller, must contain at least `count' elements. */ + /* */ + /* If scaling is performed (based on the value of */ + /* `load_flags'), the advance values are in 16.16 format. */ + /* Otherwise, they are in font units. */ + /* */ + /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ + /* vertical advances corresponding to a vertical layout. */ + /* Otherwise, they are the horizontal advances in a */ + /* horizontal layout. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ + /* if the corresponding font backend doesn't have a quick way to */ + /* retrieve the advances. */ + /* */ + /* Scaled advances are returned in 16.16 format but aren't */ + /* transformed by the affine transformation specified by */ + /* @FT_Set_Transform. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Advances( FT_Face face, + FT_UInt start, + FT_UInt count, + FT_Int32 load_flags, + FT_Fixed *padvances ); + + /* */ + + +FT_END_HEADER + +#endif /* FTADVANC_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftautoh.h b/foreign/freetype2/freetype/ftautoh.h new file mode 100644 index 0000000..8052dd2 --- /dev/null +++ b/foreign/freetype2/freetype/ftautoh.h @@ -0,0 +1,503 @@ +/***************************************************************************/ +/* */ +/* ftautoh.h */ +/* */ +/* FreeType API for controlling the auto-hinter (specification only). */ +/* */ +/* Copyright 2012-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTAUTOH_H_ +#define FTAUTOH_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * auto_hinter + * + * @title: + * The auto-hinter + * + * @abstract: + * Controlling the auto-hinting module. + * + * @description: + * While FreeType's auto-hinter doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. The following lists the available properties + * together with the necessary macros and structures. + * + * Note that the auto-hinter's module name is `autofitter' for + * historical reasons. + * + */ + + + /************************************************************************** + * + * @property: + * glyph-to-script-map + * + * @description: + * *Experimental* *only* + * + * The auto-hinter provides various script modules to hint glyphs. + * Examples of supported scripts are Latin or CJK. Before a glyph is + * auto-hinted, the Unicode character map of the font gets examined, and + * the script is then determined based on Unicode character ranges, see + * below. + * + * OpenType fonts, however, often provide much more glyphs than + * character codes (small caps, superscripts, ligatures, swashes, etc.), + * to be controlled by so-called `features'. Handling OpenType features + * can be quite complicated and thus needs a separate library on top of + * FreeType. + * + * The mapping between glyph indices and scripts (in the auto-hinter + * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an + * array with `num_glyphs' elements, as found in the font's @FT_Face + * structure. The `glyph-to-script-map' property returns a pointer to + * this array, which can be modified as needed. Note that the + * modification should happen before the first glyph gets processed by + * the auto-hinter so that the global analysis of the font shapes + * actually uses the modified mapping. + * + * The following example code demonstrates how to access it (omitting + * the error handling). + * + * { + * FT_Library library; + * FT_Face face; + * FT_Prop_GlyphToScriptMap prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * + * prop.face = face; + * + * FT_Property_Get( library, "autofitter", + * "glyph-to-script-map", &prop ); + * + * // adjust `prop.map' as needed right here + * + * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); + * } + * + */ + + + /************************************************************************** + * + * @enum: + * FT_AUTOHINTER_SCRIPT_XXX + * + * @description: + * *Experimental* *only* + * + * A list of constants used for the @glyph-to-script-map property to + * specify the script submodule the auto-hinter should use for hinting a + * particular glyph. + * + * @values: + * FT_AUTOHINTER_SCRIPT_NONE :: + * Don't auto-hint this glyph. + * + * FT_AUTOHINTER_SCRIPT_LATIN :: + * Apply the latin auto-hinter. For the auto-hinter, `latin' is a + * very broad term, including Cyrillic and Greek also since characters + * from those scripts share the same design constraints. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+0020 - U+007F // Basic Latin (no control characters) + * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) + * U+0100 - U+017F // Latin Extended-A + * U+0180 - U+024F // Latin Extended-B + * U+0250 - U+02AF // IPA Extensions + * U+02B0 - U+02FF // Spacing Modifier Letters + * U+0300 - U+036F // Combining Diacritical Marks + * U+0370 - U+03FF // Greek and Coptic + * U+0400 - U+04FF // Cyrillic + * U+0500 - U+052F // Cyrillic Supplement + * U+1D00 - U+1D7F // Phonetic Extensions + * U+1D80 - U+1DBF // Phonetic Extensions Supplement + * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement + * U+1E00 - U+1EFF // Latin Extended Additional + * U+1F00 - U+1FFF // Greek Extended + * U+2000 - U+206F // General Punctuation + * U+2070 - U+209F // Superscripts and Subscripts + * U+20A0 - U+20CF // Currency Symbols + * U+2150 - U+218F // Number Forms + * U+2460 - U+24FF // Enclosed Alphanumerics + * U+2C60 - U+2C7F // Latin Extended-C + * U+2DE0 - U+2DFF // Cyrillic Extended-A + * U+2E00 - U+2E7F // Supplemental Punctuation + * U+A640 - U+A69F // Cyrillic Extended-B + * U+A720 - U+A7FF // Latin Extended-D + * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) + * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols + * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement + * } + * + * FT_AUTOHINTER_SCRIPT_CJK :: + * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old + * Vietnamese, and some other scripts. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+1100 - U+11FF // Hangul Jamo + * U+2E80 - U+2EFF // CJK Radicals Supplement + * U+2F00 - U+2FDF // Kangxi Radicals + * U+2FF0 - U+2FFF // Ideographic Description Characters + * U+3000 - U+303F // CJK Symbols and Punctuation + * U+3040 - U+309F // Hiragana + * U+30A0 - U+30FF // Katakana + * U+3100 - U+312F // Bopomofo + * U+3130 - U+318F // Hangul Compatibility Jamo + * U+3190 - U+319F // Kanbun + * U+31A0 - U+31BF // Bopomofo Extended + * U+31C0 - U+31EF // CJK Strokes + * U+31F0 - U+31FF // Katakana Phonetic Extensions + * U+3200 - U+32FF // Enclosed CJK Letters and Months + * U+3300 - U+33FF // CJK Compatibility + * U+3400 - U+4DBF // CJK Unified Ideographs Extension A + * U+4DC0 - U+4DFF // Yijing Hexagram Symbols + * U+4E00 - U+9FFF // CJK Unified Ideographs + * U+A960 - U+A97F // Hangul Jamo Extended-A + * U+AC00 - U+D7AF // Hangul Syllables + * U+D7B0 - U+D7FF // Hangul Jamo Extended-B + * U+F900 - U+FAFF // CJK Compatibility Ideographs + * U+FE10 - U+FE1F // Vertical forms + * U+FE30 - U+FE4F // CJK Compatibility Forms + * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms + * U+1B000 - U+1B0FF // Kana Supplement + * U+1D300 - U+1D35F // Tai Xuan Hing Symbols + * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement + * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B + * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C + * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D + * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement + * } + * + * FT_AUTOHINTER_SCRIPT_INDIC :: + * Apply the indic auto-hinter, covering all major scripts from the + * Indian sub-continent and some other related scripts like Thai, Lao, + * or Tibetan. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+0900 - U+0DFF // Indic Range + * U+0F00 - U+0FFF // Tibetan + * U+1900 - U+194F // Limbu + * U+1B80 - U+1BBF // Sundanese + * U+1C80 - U+1CDF // Meetei Mayak + * U+A800 - U+A82F // Syloti Nagri + * U+11800 - U+118DF // Sharada + * } + * + * Note that currently Indic support is rudimentary only, missing blue + * zone support. + * + */ +#define FT_AUTOHINTER_SCRIPT_NONE 0 +#define FT_AUTOHINTER_SCRIPT_LATIN 1 +#define FT_AUTOHINTER_SCRIPT_CJK 2 +#define FT_AUTOHINTER_SCRIPT_INDIC 3 + + + /************************************************************************** + * + * @struct: + * FT_Prop_GlyphToScriptMap + * + * @description: + * *Experimental* *only* + * + * The data exchange structure for the @glyph-to-script-map property. + * + */ + typedef struct FT_Prop_GlyphToScriptMap_ + { + FT_Face face; + FT_UShort* map; + + } FT_Prop_GlyphToScriptMap; + + + /************************************************************************** + * + * @property: + * fallback-script + * + * @description: + * *Experimental* *only* + * + * If no auto-hinter script module can be assigned to a glyph, a + * fallback script gets assigned to it (see also the + * @glyph-to-script-map property). By default, this is + * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, + * this fallback value can be changed. + * + * { + * FT_Library library; + * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "fallback-script", &fallback_script ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the + * fallback script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the fallback script will affect this face. + * + */ + + + /************************************************************************** + * + * @property: + * default-script + * + * @description: + * *Experimental* *only* + * + * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make + * the HarfBuzz library access OpenType features for getting better + * glyph coverages, this property sets the (auto-fitter) script to be + * used for the default (OpenType) script data of a font's GSUB table. + * Features for the default script are intended for all scripts not + * explicitly handled in GSUB; an example is a `dlig' feature, + * containing the combination of the characters `T', `E', and `L' to + * form a `TEL' ligature. + * + * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the + * `default-script' property, this default value can be changed. + * + * { + * FT_Library library; + * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "default-script", &default_script ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the + * default script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the default script will affect this face. + * + */ + + + /************************************************************************** + * + * @property: + * increase-x-height + * + * @description: + * For ppem values in the range 6~<= ppem <= `increase-x-height', round + * up the font's x~height much more often than normally. If the value + * is set to~0, which is the default, this feature is switched off. Use + * this property to improve the legibility of small font sizes if + * necessary. + * + * { + * FT_Library library; + * FT_Face face; + * FT_Prop_IncreaseXHeight prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); + * + * prop.face = face; + * prop.limit = 14; + * + * FT_Property_Set( library, "autofitter", + * "increase-x-height", &prop ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * Set this value right after calling @FT_Set_Char_Size, but before + * loading any glyph (using the auto-hinter). + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Prop_IncreaseXHeight + * + * @description: + * The data exchange structure for the @increase-x-height property. + * + */ + typedef struct FT_Prop_IncreaseXHeight_ + { + FT_Face face; + FT_UInt limit; + + } FT_Prop_IncreaseXHeight; + + + /************************************************************************** + * + * @property: + * warping + * + * @description: + * *Experimental* *only* + * + * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to + * activate the warp hinting code in the auto-hinter, this property + * switches warping on and off. + * + * Warping only works in `light' auto-hinting mode. The idea of the + * code is to slightly scale and shift a glyph along the non-hinted + * dimension (which is usually the horizontal axis) so that as much of + * its segments are aligned (more or less) to the grid. To find out a + * glyph's optimal scaling and shifting value, various parameter + * combinations are tried and scored. + * + * By default, warping is off. The example below shows how to switch on + * warping (omitting the error handling). + * + * { + * FT_Library library; + * FT_Bool warping = 1; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "warping", &warping ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * The warping code can also change advance widths. Have a look at the + * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure + * for details on improving inter-glyph distances while rendering. + * + * Since warping is a global property of the auto-hinter it is best to + * change its value before rendering any face. Otherwise, you should + * reload all faces that get auto-hinted in `light' hinting mode. + * + */ + + + /************************************************************************** + * + * @property: + * no-stem-darkening[autofit] + * + * @description: + * *Experimental* *only,* *requires* *linear* *alpha* *blending* *and* + * *gamma* *correction* + * + * Stem darkening emboldens glyphs at smaller sizes to make them more + * readable on common low-DPI screens when using linear alpha blending + * and gamma correction, see @FT_Render_Glyph. When not using linear + * alpha blending and gamma correction, glyphs will appear heavy and + * fuzzy! + * + * Gamma correction essentially lightens fonts since shades of grey are + * shifted to higher pixel values (=~higher brightness) to match the + * original intention to the reality of our screens. The side-effect is + * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font + * rendering library implement a counter-measure: stem darkening at + * smaller sizes where shades of gray dominate. By emboldening a glyph + * slightly in relation to its pixel size, individual pixels get higher + * coverage of filled-in outlines and are therefore `blacker'. This + * counteracts the `thinning out' of glyphs, making text remain readable + * at smaller sizes. All glyphs that pass through the auto-hinter will + * be emboldened unless this property is set to TRUE. + * + * See the description of the CFF driver for algorithmic details. Total + * consistency with the CFF driver is currently not achieved because the + * emboldening method differs and glyphs must be scaled down on the + * Y-axis to keep outline points inside their precomputed blue zones. + * The smaller the size (especially 9ppem and down), the higher the loss + * of emboldening versus the CFF driver. + * + */ + + + /************************************************************************** + * + * @property: + * darkening-parameters[autofit] + * + * @description: + * *Experimental* *only* + * + * See the description of the CFF driver for details. This + * implementation appropriates the + * CFF_CONFIG_OPTION_DARKENING_PARAMETER_* #defines for consistency. + * Note the differences described in @no-stem-darkening[autofit]. + * + */ + + + /* */ + + +FT_END_HEADER + +#endif /* FTAUTOH_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftbbox.h b/foreign/freetype2/freetype/ftbbox.h new file mode 100644 index 0000000..2a4d214 --- /dev/null +++ b/foreign/freetype2/freetype/ftbbox.h @@ -0,0 +1,101 @@ +/***************************************************************************/ +/* */ +/* ftbbox.h */ +/* */ +/* FreeType exact bbox computation (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This component has a _single_ role: to compute exact outline bounding */ + /* boxes. */ + /* */ + /* It is separated from the rest of the engine for various technical */ + /* reasons. It may well be integrated in `ftoutln' later. */ + /* */ + /*************************************************************************/ + + +#ifndef FTBBOX_H_ +#define FTBBOX_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_BBox */ + /* */ + /* <Description> */ + /* Compute the exact bounding box of an outline. This is slower */ + /* than computing the control box. However, it uses an advanced */ + /* algorithm that returns _very_ quickly when the two boxes */ + /* coincide. Otherwise, the outline Bézier arcs are traversed to */ + /* extract their extrema. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source outline. */ + /* */ + /* <Output> */ + /* abbox :: The outline's exact bounding box. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If the font is tricky and the glyph has been loaded with */ + /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ + /* reasonable values for the BBox it is necessary to load the glyph */ + /* at a large ppem value (so that the hinting instructions can */ + /* properly shift and scale the subglyphs), then extracting the BBox, */ + /* which can be eventually converted back to font units. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_BBox( FT_Outline* outline, + FT_BBox *abbox ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBBOX_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/ftbdf.h b/foreign/freetype2/freetype/ftbdf.h new file mode 100644 index 0000000..016dba0 --- /dev/null +++ b/foreign/freetype2/freetype/ftbdf.h @@ -0,0 +1,210 @@ +/***************************************************************************/ +/* */ +/* ftbdf.h */ +/* */ +/* FreeType API for accessing BDF-specific strings (specification). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBDF_H_ +#define FTBDF_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bdf_fonts */ + /* */ + /* <Title> */ + /* BDF and PCF Files */ + /* */ + /* <Abstract> */ + /* BDF and PCF specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions specific to BDF */ + /* and PCF fonts. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @enum: + * BDF_PropertyType + * + * @description: + * A list of BDF property types. + * + * @values: + * BDF_PROPERTY_TYPE_NONE :: + * Value~0 is used to indicate a missing property. + * + * BDF_PROPERTY_TYPE_ATOM :: + * Property is a string atom. + * + * BDF_PROPERTY_TYPE_INTEGER :: + * Property is a 32-bit signed integer. + * + * BDF_PROPERTY_TYPE_CARDINAL :: + * Property is a 32-bit unsigned integer. + */ + typedef enum BDF_PropertyType_ + { + BDF_PROPERTY_TYPE_NONE = 0, + BDF_PROPERTY_TYPE_ATOM = 1, + BDF_PROPERTY_TYPE_INTEGER = 2, + BDF_PROPERTY_TYPE_CARDINAL = 3 + + } BDF_PropertyType; + + + /********************************************************************** + * + * @type: + * BDF_Property + * + * @description: + * A handle to a @BDF_PropertyRec structure to model a given + * BDF/PCF property. + */ + typedef struct BDF_PropertyRec_* BDF_Property; + + + /********************************************************************** + * + * @struct: + * BDF_PropertyRec + * + * @description: + * This structure models a given BDF/PCF property. + * + * @fields: + * type :: + * The property type. + * + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be + * NULL, indicating an empty string. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. + */ + typedef struct BDF_PropertyRec_ + { + BDF_PropertyType type; + union { + const char* atom; + FT_Int32 integer; + FT_UInt32 cardinal; + + } u; + + } BDF_PropertyRec; + + + /********************************************************************** + * + * @function: + * FT_Get_BDF_Charset_ID + * + * @description: + * Retrieve a BDF font character set identity, according to + * the BDF specification. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * acharset_encoding :: + * Charset encoding, as a C~string, owned by the face. + * + * acharset_registry :: + * Charset registry, as a C~string, owned by the face. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with BDF faces, returning an error otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Charset_ID( FT_Face face, + const char* *acharset_encoding, + const char* *acharset_registry ); + + + /********************************************************************** + * + * @function: + * FT_Get_BDF_Property + * + * @description: + * Retrieve a BDF property from a BDF or PCF font file. + * + * @input: + * face :: A handle to the input face. + * + * name :: The property name. + * + * @output: + * aproperty :: The property. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function works with BDF _and_ PCF fonts. It returns an error + * otherwise. It also returns an error if the property is not in the + * font. + * + * A `property' is a either key-value pair within the STARTPROPERTIES + * ... ENDPROPERTIES block of a BDF font or a key-value pair from the + * `info->props' array within a `FontRec' structure of a PCF font. + * + * Integer properties are always stored as `signed' within PCF fonts; + * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value + * for BDF fonts only. + * + * In case of error, `aproperty->type' is always set to + * @BDF_PROPERTY_TYPE_NONE. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Property( FT_Face face, + const char* prop_name, + BDF_PropertyRec *aproperty ); + + /* */ + +FT_END_HEADER + +#endif /* FTBDF_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftbitmap.h b/foreign/freetype2/freetype/ftbitmap.h new file mode 100644 index 0000000..0eac7b9 --- /dev/null +++ b/foreign/freetype2/freetype/ftbitmap.h @@ -0,0 +1,240 @@ +/***************************************************************************/ +/* */ +/* ftbitmap.h */ +/* */ +/* FreeType utility functions for bitmaps (specification). */ +/* */ +/* Copyright 2004-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBITMAP_H_ +#define FTBITMAP_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bitmap_handling */ + /* */ + /* <Title> */ + /* Bitmap Handling */ + /* */ + /* <Abstract> */ + /* Handling FT_Bitmap objects. */ + /* */ + /* <Description> */ + /* This section contains functions for handling @FT_Bitmap objects. */ + /* Note that none of the functions changes the bitmap's `flow' (as */ + /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Init */ + /* */ + /* <Description> */ + /* Initialize a pointer to an @FT_Bitmap structure. */ + /* */ + /* <InOut> */ + /* abitmap :: A pointer to the bitmap structure. */ + /* */ + /* <Note> */ + /* A deprecated name for the same function is `FT_Bitmap_New'. */ + /* */ + FT_EXPORT( void ) + FT_Bitmap_Init( FT_Bitmap *abitmap ); + + + /* deprecated */ + FT_EXPORT( void ) + FT_Bitmap_New( FT_Bitmap *abitmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Copy */ + /* */ + /* <Description> */ + /* Copy a bitmap into another one. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* source :: A handle to the source bitmap. */ + /* */ + /* <Output> */ + /* target :: A handle to the target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Copy( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Embolden */ + /* */ + /* <Description> */ + /* Embolden a bitmap. The new bitmap will be about `xStrength' */ + /* pixels wider and `yStrength' pixels higher. The left and bottom */ + /* borders are kept unchanged. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* xStrength :: How strong the glyph is emboldened horizontally. */ + /* Expressed in 26.6 pixel format. */ + /* */ + /* yStrength :: How strong the glyph is emboldened vertically. */ + /* Expressed in 26.6 pixel format. */ + /* */ + /* <InOut> */ + /* bitmap :: A handle to the target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The current implementation restricts `xStrength' to be less than */ + /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ + /* */ + /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ + /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ + /* */ + /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */ + /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Embolden( FT_Library library, + FT_Bitmap* bitmap, + FT_Pos xStrength, + FT_Pos yStrength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Convert */ + /* */ + /* <Description> */ + /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ + /* to a bitmap object with depth 8bpp, making the number of used */ + /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* source :: The source bitmap. */ + /* */ + /* alignment :: The pitch of the bitmap is a multiple of this */ + /* parameter. Common values are 1, 2, or 4. */ + /* */ + /* <Output> */ + /* target :: The target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* It is possible to call @FT_Bitmap_Convert multiple times without */ + /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ + /* */ + /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ + /* */ + /* The `library' argument is taken to have access to FreeType's */ + /* memory handling functions. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Convert( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target, + FT_Int alignment ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GlyphSlot_Own_Bitmap */ + /* */ + /* <Description> */ + /* Make sure that a glyph slot owns `slot->bitmap'. */ + /* */ + /* <Input> */ + /* slot :: The glyph slot. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function is to be used in combination with */ + /* @FT_Bitmap_Embolden. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Done */ + /* */ + /* <Description> */ + /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* bitmap :: The bitmap object to be freed. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `library' argument is taken to have access to FreeType's */ + /* memory handling functions. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Done( FT_Library library, + FT_Bitmap *bitmap ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTBITMAP_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftbzip2.h b/foreign/freetype2/freetype/ftbzip2.h new file mode 100644 index 0000000..b7f2eee --- /dev/null +++ b/foreign/freetype2/freetype/ftbzip2.h @@ -0,0 +1,102 @@ +/***************************************************************************/ +/* */ +/* ftbzip2.h */ +/* */ +/* Bzip2-compressed stream support. */ +/* */ +/* Copyright 2010-2016 by */ +/* Joel Klinghed. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBZIP2_H_ +#define FTBZIP2_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bzip2 */ + /* */ + /* <Title> */ + /* BZIP2 Streams */ + /* */ + /* <Abstract> */ + /* Using bzip2-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Bzip2-specific functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************ + * + * @function: + * FT_Stream_OpenBzip2 + * + * @description: + * Open a new stream to parse bzip2-compressed font files. This is + * mainly used to support the compressed `*.pcf.bz2' fonts that come + * with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, bzip2 compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a bzip2 compressed stream + * from it and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with bzip2 support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenBzip2( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBZIP2_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftcache.h b/foreign/freetype2/freetype/ftcache.h new file mode 100644 index 0000000..6c9f2c4 --- /dev/null +++ b/foreign/freetype2/freetype/ftcache.h @@ -0,0 +1,1057 @@ +/***************************************************************************/ +/* */ +/* ftcache.h */ +/* */ +/* FreeType Cache subsystem (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCACHE_H_ +#define FTCACHE_H_ + + +#include <ft2build.h> +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /************************************************************************* + * + * <Section> + * cache_subsystem + * + * <Title> + * Cache Sub-System + * + * <Abstract> + * How to cache face, size, and glyph data with FreeType~2. + * + * <Description> + * This section describes the FreeType~2 cache sub-system, which is used + * to limit the number of concurrently opened @FT_Face and @FT_Size + * objects, as well as caching information like character maps and glyph + * images while limiting their maximum memory usage. + * + * Note that all types and functions begin with the `FTC_' prefix. + * + * The cache is highly portable and thus doesn't know anything about the + * fonts installed on your system, or how to access them. This implies + * the following scheme: + * + * First, available or installed font faces are uniquely identified by + * @FTC_FaceID values, provided to the cache by the client. Note that + * the cache only stores and compares these values, and doesn't try to + * interpret them in any way. + * + * Second, the cache calls, only when needed, a client-provided function + * to convert an @FTC_FaceID into a new @FT_Face object. The latter is + * then completely managed by the cache, including its termination + * through @FT_Done_Face. To monitor termination of face objects, the + * finalizer callback in the `generic' field of the @FT_Face object can + * be used, which might also be used to store the @FTC_FaceID of the + * face. + * + * Clients are free to map face IDs to anything else. The most simple + * usage is to associate them to a (pathname,face_index) pair that is + * used to call @FT_New_Face. However, more complex schemes are also + * possible. + * + * Note that for the cache to work correctly, the face ID values must be + * *persistent*, which means that the contents they point to should not + * change at runtime, or that their value should not become invalid. + * + * If this is unavoidable (e.g., when a font is uninstalled at runtime), + * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let + * the cache get rid of any references to the old @FTC_FaceID it may + * keep internally. Failure to do so will lead to incorrect behaviour + * or even crashes. + * + * To use the cache, start with calling @FTC_Manager_New to create a new + * @FTC_Manager object, which models a single cache instance. You can + * then look up @FT_Face and @FT_Size objects with + * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively. + * + * If you want to use the charmap caching, call @FTC_CMapCache_New, then + * later use @FTC_CMapCache_Lookup to perform the equivalent of + * @FT_Get_Char_Index, only much faster. + * + * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then + * later use @FTC_ImageCache_Lookup to retrieve the corresponding + * @FT_Glyph objects from the cache. + * + * If you need lots of small bitmaps, it is much more memory efficient + * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This + * returns @FTC_SBitRec structures, which are used to store small + * bitmaps directly. (A small bitmap is one whose metrics and + * dimensions all fit into 8-bit integers). + * + * We hope to also provide a kerning cache in the near future. + * + * + * <Order> + * FTC_Manager + * FTC_FaceID + * FTC_Face_Requester + * + * FTC_Manager_New + * FTC_Manager_Reset + * FTC_Manager_Done + * FTC_Manager_LookupFace + * FTC_Manager_LookupSize + * FTC_Manager_RemoveFaceID + * + * FTC_Node + * FTC_Node_Unref + * + * FTC_ImageCache + * FTC_ImageCache_New + * FTC_ImageCache_Lookup + * + * FTC_SBit + * FTC_SBitCache + * FTC_SBitCache_New + * FTC_SBitCache_Lookup + * + * FTC_CMapCache + * FTC_CMapCache_New + * FTC_CMapCache_Lookup + * + *************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** BASIC TYPE DEFINITIONS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: FTC_FaceID + * + * @description: + * An opaque pointer type that is used to identity face objects. The + * contents of such objects is application-dependent. + * + * These pointers are typically used to point to a user-defined + * structure containing a font file path, and face index. + * + * @note: + * Never use NULL as a valid @FTC_FaceID. + * + * Face IDs are passed by the client to the cache manager that calls, + * when needed, the @FTC_Face_Requester to translate them into new + * @FT_Face objects. + * + * If the content of a given face ID changes at runtime, or if the value + * becomes invalid (e.g., when uninstalling a font), you should + * immediately call @FTC_Manager_RemoveFaceID before any other cache + * function. + * + * Failure to do so will result in incorrect behaviour or even + * memory leaks and crashes. + */ + typedef FT_Pointer FTC_FaceID; + + + /************************************************************************ + * + * @functype: + * FTC_Face_Requester + * + * @description: + * A callback function provided by client applications. It is used by + * the cache manager to translate a given @FTC_FaceID into a new valid + * @FT_Face object, on demand. + * + * <Input> + * face_id :: + * The face ID to resolve. + * + * library :: + * A handle to a FreeType library object. + * + * req_data :: + * Application-provided request data (see note below). + * + * <Output> + * aface :: + * A new @FT_Face handle. + * + * <Return> + * FreeType error code. 0~means success. + * + * <Note> + * The third parameter `req_data' is the same as the one passed by the + * client when @FTC_Manager_New is called. + * + * The face requester should not perform funny things on the returned + * face object, like creating a new @FT_Size for it, or setting a + * transformation through @FT_Set_Transform! + */ + typedef FT_Error + (*FTC_Face_Requester)( FTC_FaceID face_id, + FT_Library library, + FT_Pointer req_data, + FT_Face* aface ); + + /* */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** CACHE MANAGER OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_Manager */ + /* */ + /* <Description> */ + /* This object corresponds to one instance of the cache-subsystem. */ + /* It is used to cache one or more @FT_Face objects, along with */ + /* corresponding @FT_Size objects. */ + /* */ + /* The manager intentionally limits the total number of opened */ + /* @FT_Face and @FT_Size objects to control memory usage. See the */ + /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ + /* */ + /* The manager is also used to cache `nodes' of various types while */ + /* limiting their total memory usage. */ + /* */ + /* All limitations are enforced by keeping lists of managed objects */ + /* in most-recently-used order, and flushing old nodes to make room */ + /* for new ones. */ + /* */ + typedef struct FTC_ManagerRec_* FTC_Manager; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_Node */ + /* */ + /* <Description> */ + /* An opaque handle to a cache node object. Each cache node is */ + /* reference-counted. A node with a count of~0 might be flushed */ + /* out of a full cache whenever a lookup request is performed. */ + /* */ + /* If you look up nodes, you have the ability to `acquire' them, */ + /* i.e., to increment their reference count. This will prevent the */ + /* node from being flushed out of the cache until you explicitly */ + /* `release' it (see @FTC_Node_Unref). */ + /* */ + /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ + /* */ + typedef struct FTC_NodeRec_* FTC_Node; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_New */ + /* */ + /* <Description> */ + /* Create a new cache manager. */ + /* */ + /* <Input> */ + /* library :: The parent FreeType library handle to use. */ + /* */ + /* max_faces :: Maximum number of opened @FT_Face objects managed by */ + /* this cache instance. Use~0 for defaults. */ + /* */ + /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ + /* this cache instance. Use~0 for defaults. */ + /* */ + /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ + /* Use~0 for defaults. Note that this value does not */ + /* account for managed @FT_Face and @FT_Size objects. */ + /* */ + /* requester :: An application-provided callback used to translate */ + /* face IDs into real @FT_Face objects. */ + /* */ + /* req_data :: A generic pointer that is passed to the requester */ + /* each time it is called (see @FTC_Face_Requester). */ + /* */ + /* <Output> */ + /* amanager :: A handle to a new manager object. 0~in case of */ + /* failure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_New( FT_Library library, + FT_UInt max_faces, + FT_UInt max_sizes, + FT_ULong max_bytes, + FTC_Face_Requester requester, + FT_Pointer req_data, + FTC_Manager *amanager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_Reset */ + /* */ + /* <Description> */ + /* Empty a given cache manager. This simply gets rid of all the */ + /* currently cached @FT_Face and @FT_Size objects within the manager. */ + /* */ + /* <InOut> */ + /* manager :: A handle to the manager. */ + /* */ + FT_EXPORT( void ) + FTC_Manager_Reset( FTC_Manager manager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_Done */ + /* */ + /* <Description> */ + /* Destroy a given manager after emptying it. */ + /* */ + /* <Input> */ + /* manager :: A handle to the target cache manager object. */ + /* */ + FT_EXPORT( void ) + FTC_Manager_Done( FTC_Manager manager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_LookupFace */ + /* */ + /* <Description> */ + /* Retrieve the @FT_Face object that corresponds to a given face ID */ + /* through a cache manager. */ + /* */ + /* <Input> */ + /* manager :: A handle to the cache manager. */ + /* */ + /* face_id :: The ID of the face object. */ + /* */ + /* <Output> */ + /* aface :: A handle to the face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned @FT_Face object is always owned by the manager. You */ + /* should never try to discard it yourself. */ + /* */ + /* The @FT_Face object doesn't necessarily have a current size object */ + /* (i.e., face->size can be~0). If you need a specific `font size', */ + /* use @FTC_Manager_LookupSize instead. */ + /* */ + /* Never change the face's transformation matrix (i.e., never call */ + /* the @FT_Set_Transform function) on a returned face! If you need */ + /* to transform glyphs, do it yourself after glyph loading. */ + /* */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory was available */ + /* for the operation. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupFace( FTC_Manager manager, + FTC_FaceID face_id, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_ScalerRec */ + /* */ + /* <Description> */ + /* A structure used to describe a given character size in either */ + /* pixels or points to the cache manager. See */ + /* @FTC_Manager_LookupSize. */ + /* */ + /* <Fields> */ + /* face_id :: The source face ID. */ + /* */ + /* width :: The character width. */ + /* */ + /* height :: The character height. */ + /* */ + /* pixel :: A Boolean. If 1, the `width' and `height' fields are */ + /* interpreted as integer pixel character sizes. */ + /* Otherwise, they are expressed as 1/64th of points. */ + /* */ + /* x_res :: Only used when `pixel' is value~0 to indicate the */ + /* horizontal resolution in dpi. */ + /* */ + /* y_res :: Only used when `pixel' is value~0 to indicate the */ + /* vertical resolution in dpi. */ + /* */ + /* <Note> */ + /* This type is mainly used to retrieve @FT_Size objects through the */ + /* cache manager. */ + /* */ + typedef struct FTC_ScalerRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int pixel; + FT_UInt x_res; + FT_UInt y_res; + + } FTC_ScalerRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_Scaler */ + /* */ + /* <Description> */ + /* A handle to an @FTC_ScalerRec structure. */ + /* */ + typedef struct FTC_ScalerRec_* FTC_Scaler; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_LookupSize */ + /* */ + /* <Description> */ + /* Retrieve the @FT_Size object that corresponds to a given */ + /* @FTC_ScalerRec pointer through a cache manager. */ + /* */ + /* <Input> */ + /* manager :: A handle to the cache manager. */ + /* */ + /* scaler :: A scaler handle. */ + /* */ + /* <Output> */ + /* asize :: A handle to the size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned @FT_Size object is always owned by the manager. You */ + /* should never try to discard it by yourself. */ + /* */ + /* You can access the parent @FT_Face object simply as `size->face' */ + /* if you need it. Note that this object is also owned by the */ + /* manager. */ + /* */ + /* <Note> */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory is available */ + /* for the operation. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupSize( FTC_Manager manager, + FTC_Scaler scaler, + FT_Size *asize ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Node_Unref */ + /* */ + /* <Description> */ + /* Decrement a cache node's internal reference count. When the count */ + /* reaches 0, it is not destroyed but becomes eligible for subsequent */ + /* cache flushes. */ + /* */ + /* <Input> */ + /* node :: The cache node handle. */ + /* */ + /* manager :: The cache manager handle. */ + /* */ + FT_EXPORT( void ) + FTC_Node_Unref( FTC_Node node, + FTC_Manager manager ); + + + /************************************************************************* + * + * @function: + * FTC_Manager_RemoveFaceID + * + * @description: + * A special function used to indicate to the cache manager that + * a given @FTC_FaceID is no longer valid, either because its + * content changed, or because it was deallocated or uninstalled. + * + * @input: + * manager :: + * The cache manager handle. + * + * face_id :: + * The @FTC_FaceID to be removed. + * + * @note: + * This function flushes all nodes from the cache corresponding to this + * `face_id', with the exception of nodes with a non-null reference + * count. + * + * Such nodes are however modified internally so as to never appear + * in later lookups with the same `face_id' value, and to be immediately + * destroyed when released by all their users. + * + */ + FT_EXPORT( void ) + FTC_Manager_RemoveFaceID( FTC_Manager manager, + FTC_FaceID face_id ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* cache_subsystem */ + /* */ + /*************************************************************************/ + + /************************************************************************* + * + * @type: + * FTC_CMapCache + * + * @description: + * An opaque handle used to model a charmap cache. This cache is to + * hold character codes -> glyph indices mappings. + * + */ + typedef struct FTC_CMapCacheRec_* FTC_CMapCache; + + + /************************************************************************* + * + * @function: + * FTC_CMapCache_New + * + * @description: + * Create a new charmap cache. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * @output: + * acache :: + * A new cache handle. NULL in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Like all other caches, this one will be destroyed with the cache + * manager. + * + */ + FT_EXPORT( FT_Error ) + FTC_CMapCache_New( FTC_Manager manager, + FTC_CMapCache *acache ); + + + /************************************************************************ + * + * @function: + * FTC_CMapCache_Lookup + * + * @description: + * Translate a character code into a glyph index, using the charmap + * cache. + * + * @input: + * cache :: + * A charmap cache handle. + * + * face_id :: + * The source face ID. + * + * cmap_index :: + * The index of the charmap in the source face. Any negative value + * means to use the cache @FT_Face's default charmap. + * + * char_code :: + * The character code (in the corresponding charmap). + * + * @return: + * Glyph index. 0~means `no glyph'. + * + */ + FT_EXPORT( FT_UInt ) + FTC_CMapCache_Lookup( FTC_CMapCache cache, + FTC_FaceID face_id, + FT_Int cmap_index, + FT_UInt32 char_code ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* cache_subsystem */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** IMAGE CACHE OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************* + * + * @struct: + * FTC_ImageTypeRec + * + * @description: + * A structure used to model the type of images in a glyph cache. + * + * @fields: + * face_id :: + * The face ID. + * + * width :: + * The width in pixels. + * + * height :: + * The height in pixels. + * + * flags :: + * The load flags, as in @FT_Load_Glyph. + * + */ + typedef struct FTC_ImageTypeRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int32 flags; + + } FTC_ImageTypeRec; + + + /************************************************************************* + * + * @type: + * FTC_ImageType + * + * @description: + * A handle to an @FTC_ImageTypeRec structure. + * + */ + typedef struct FTC_ImageTypeRec_* FTC_ImageType; + + + /* */ + + +#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ + ( (d1)->face_id == (d2)->face_id && \ + (d1)->width == (d2)->width && \ + (d1)->flags == (d2)->flags ) + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_ImageCache */ + /* */ + /* <Description> */ + /* A handle to a glyph image cache object. They are designed to */ + /* hold many distinct glyph images while not exceeding a certain */ + /* memory threshold. */ + /* */ + typedef struct FTC_ImageCacheRec_* FTC_ImageCache; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_New */ + /* */ + /* <Description> */ + /* Create a new glyph image cache. */ + /* */ + /* <Input> */ + /* manager :: The parent manager for the image cache. */ + /* */ + /* <Output> */ + /* acache :: A handle to the new glyph image cache object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_New( FTC_Manager manager, + FTC_ImageCache *acache ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_Lookup */ + /* */ + /* <Description> */ + /* Retrieve a given glyph image from a glyph image cache. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source glyph image cache. */ + /* */ + /* type :: A pointer to a glyph image type descriptor. */ + /* */ + /* gindex :: The glyph index to retrieve. */ + /* */ + /* <Output> */ + /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ + /* failure. */ + /* */ + /* anode :: Used to return the address of of the corresponding cache */ + /* node after incrementing its reference count (see note */ + /* below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned glyph is owned and managed by the glyph image cache. */ + /* Never try to transform or discard it manually! You can however */ + /* create a copy with @FT_Glyph_Copy and modify the new one. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the glyph image, after increasing its reference */ + /* count. This ensures that the node (as well as the @FT_Glyph) will */ + /* always be kept in the cache until you call @FTC_Node_Unref to */ + /* `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the @FT_Glyph could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_Lookup( FTC_ImageCache cache, + FTC_ImageType type, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_LookupScaler */ + /* */ + /* <Description> */ + /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */ + /* to specify the face ID and its size. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source glyph image cache. */ + /* */ + /* scaler :: A pointer to a scaler descriptor. */ + /* */ + /* load_flags :: The corresponding load flags. */ + /* */ + /* gindex :: The glyph index to retrieve. */ + /* */ + /* <Output> */ + /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ + /* failure. */ + /* */ + /* anode :: Used to return the address of of the corresponding */ + /* cache node after incrementing its reference count */ + /* (see note below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned glyph is owned and managed by the glyph image cache. */ + /* Never try to transform or discard it manually! You can however */ + /* create a copy with @FT_Glyph_Copy and modify the new one. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the glyph image, after increasing its reference */ + /* count. This ensures that the node (as well as the @FT_Glyph) will */ + /* always be kept in the cache until you call @FTC_Node_Unref to */ + /* `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the @FT_Glyph could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ + /* glyphs; you should always use the FreeType cache API instead. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_LookupScaler( FTC_ImageCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_SBit */ + /* */ + /* <Description> */ + /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */ + /* structure for details. */ + /* */ + typedef struct FTC_SBitRec_* FTC_SBit; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_SBitRec */ + /* */ + /* <Description> */ + /* A very compact structure used to describe a small glyph bitmap. */ + /* */ + /* <Fields> */ + /* width :: The bitmap width in pixels. */ + /* */ + /* height :: The bitmap height in pixels. */ + /* */ + /* left :: The horizontal distance from the pen position to the */ + /* left bitmap border (a.k.a. `left side bearing', or */ + /* `lsb'). */ + /* */ + /* top :: The vertical distance from the pen position (on the */ + /* baseline) to the upper bitmap border (a.k.a. `top */ + /* side bearing'). The distance is positive for upwards */ + /* y~coordinates. */ + /* */ + /* format :: The format of the glyph bitmap (monochrome or gray). */ + /* */ + /* max_grays :: Maximum gray level value (in the range 1 to~255). */ + /* */ + /* pitch :: The number of bytes per bitmap line. May be positive */ + /* or negative. */ + /* */ + /* xadvance :: The horizontal advance width in pixels. */ + /* */ + /* yadvance :: The vertical advance height in pixels. */ + /* */ + /* buffer :: A pointer to the bitmap pixels. */ + /* */ + typedef struct FTC_SBitRec_ + { + FT_Byte width; + FT_Byte height; + FT_Char left; + FT_Char top; + + FT_Byte format; + FT_Byte max_grays; + FT_Short pitch; + FT_Char xadvance; + FT_Char yadvance; + + FT_Byte* buffer; + + } FTC_SBitRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_SBitCache */ + /* */ + /* <Description> */ + /* A handle to a small bitmap cache. These are special cache objects */ + /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */ + /* much more efficient way than the traditional glyph image cache */ + /* implemented by @FTC_ImageCache. */ + /* */ + typedef struct FTC_SBitCacheRec_* FTC_SBitCache; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_New */ + /* */ + /* <Description> */ + /* Create a new cache to store small glyph bitmaps. */ + /* */ + /* <Input> */ + /* manager :: A handle to the source cache manager. */ + /* */ + /* <Output> */ + /* acache :: A handle to the new sbit cache. NULL in case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_New( FTC_Manager manager, + FTC_SBitCache *acache ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_Lookup */ + /* */ + /* <Description> */ + /* Look up a given small glyph bitmap in a given sbit cache and */ + /* `lock' it to prevent its flushing from the cache until needed. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source sbit cache. */ + /* */ + /* type :: A pointer to the glyph image type descriptor. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* <Output> */ + /* sbit :: A handle to a small bitmap descriptor. */ + /* */ + /* anode :: Used to return the address of of the corresponding cache */ + /* node after incrementing its reference count (see note */ + /* below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The small bitmap descriptor and its bit buffer are owned by the */ + /* cache and should never be freed by the application. They might */ + /* as well disappear from memory on the next cache lookup, so don't */ + /* treat them as persistent data. */ + /* */ + /* The descriptor's `buffer' field is set to~0 to indicate a missing */ + /* glyph bitmap. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the bitmap, after increasing its reference count. */ + /* This ensures that the node (as well as the image) will always be */ + /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the bitmap could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_Lookup( FTC_SBitCache cache, + FTC_ImageType type, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_LookupScaler */ + /* */ + /* <Description> */ + /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */ + /* to specify the face ID and its size. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source sbit cache. */ + /* */ + /* scaler :: A pointer to the scaler descriptor. */ + /* */ + /* load_flags :: The corresponding load flags. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* <Output> */ + /* sbit :: A handle to a small bitmap descriptor. */ + /* */ + /* anode :: Used to return the address of of the corresponding */ + /* cache node after incrementing its reference count */ + /* (see note below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The small bitmap descriptor and its bit buffer are owned by the */ + /* cache and should never be freed by the application. They might */ + /* as well disappear from memory on the next cache lookup, so don't */ + /* treat them as persistent data. */ + /* */ + /* The descriptor's `buffer' field is set to~0 to indicate a missing */ + /* glyph bitmap. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the bitmap, after increasing its reference count. */ + /* This ensures that the node (as well as the image) will always be */ + /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the bitmap could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_LookupScaler( FTC_SBitCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCACHE_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftcffdrv.h b/foreign/freetype2/freetype/ftcffdrv.h new file mode 100644 index 0000000..9dea980 --- /dev/null +++ b/foreign/freetype2/freetype/ftcffdrv.h @@ -0,0 +1,262 @@ +/***************************************************************************/ +/* */ +/* ftcffdrv.h */ +/* */ +/* FreeType API for controlling the CFF driver (specification only). */ +/* */ +/* Copyright 2013-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCFFDRV_H_ +#define FTCFFDRV_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * cff_driver + * + * @title: + * The CFF driver + * + * @abstract: + * Controlling the CFF driver module. + * + * @description: + * While FreeType's CFF driver doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. The list below gives the available properties + * together with the necessary macros and structures. + * + * The CFF driver's module name is `cff'. + * + * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* + * + * The rasterizer is positioning horizontal features (e.g., ascender + * height & x-height, or crossbars) on the pixel grid and minimizing the + * amount of antialiasing applied to them, while placing vertical + * features (vertical stems) on the pixel grid without hinting, thus + * representing the stem position and weight accurately. Sometimes the + * vertical stems may be only partially black. In this context, + * `antialiasing' means that stems are not positioned exactly on pixel + * borders, causing a fuzzy appearance. + * + * There are two principles behind this approach. + * + * 1) No hinting in the horizontal direction: Unlike `superhinted' + * TrueType, which changes glyph widths to accommodate regular + * inter-glyph spacing, Adobe's approach is `faithful to the design' in + * representing both the glyph width and the inter-glyph spacing + * designed for the font. This makes the screen display as close as it + * can be to the result one would get with infinite resolution, while + * preserving what is considered the key characteristics of each glyph. + * Note that the distances between unhinted and grid-fitted positions at + * small sizes are comparable to kerning values and thus would be + * noticeable (and distracting) while reading if hinting were applied. + * + * One of the reasons to not hint horizontally is antialiasing for LCD + * screens: The pixel geometry of modern displays supplies three + * vertical sub-pixels as the eye moves horizontally across each visible + * pixel. On devices where we can be certain this characteristic is + * present a rasterizer can take advantage of the sub-pixels to add + * increments of weight. In Western writing systems this turns out to + * be the more critical direction anyway; the weights and spacing of + * vertical stems (see above) are central to Armenian, Cyrillic, Greek, + * and Latin type designs. Even when the rasterizer uses greyscale + * antialiasing instead of color (a necessary compromise when one + * doesn't know the screen characteristics), the unhinted vertical + * features preserve the design's weight and spacing much better than + * aliased type would. + * + * 2) Aligment in the vertical direction: Weights and spacing along the + * y~axis are less critical; what is much more important is the visual + * alignment of related features (like cap-height and x-height). The + * sense of alignment for these is enhanced by the sharpness of grid-fit + * edges, while the cruder vertical resolution (full pixels instead of + * 1/3 pixels) is less of a problem. + * + * On the technical side, horizontal alignment zones for ascender, + * x-height, and other important height values (traditionally called + * `blue zones') as defined in the font are positioned independently, + * each being rounded to the nearest pixel edge, taking care of + * overshoot suppression at small sizes, stem darkening, and scaling. + * + * Hstems (this is, hint values defined in the font to help align + * horizontal features) that fall within a blue zone are said to be + * `captured' and are aligned to that zone. Uncaptured stems are moved + * in one of four ways, top edge up or down, bottom edge up or down. + * Unless there are conflicting hstems, the smallest movement is taken + * to minimize distortion. + * + * @order: + * hinting-engine + * no-stem-darkening[cff] + * darkening-parameters[cff] + * + */ + + + /************************************************************************** + * + * @property: + * hinting-engine + * + * @description: + * Thanks to Adobe, which contributed a new hinting (and parsing) + * engine, an application can select between `freetype' and `adobe' if + * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration + * macro isn't defined, `hinting-engine' does nothing. + * + * The default engine is `freetype' if CFF_CONFIG_OPTION_OLD_ENGINE is + * defined, and `adobe' otherwise. + * + * The following example code demonstrates how to select Adobe's hinting + * engine (omitting the error handling). + * + * { + * FT_Library library; + * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "hinting-engine", &hinting_engine ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_CFF_HINTING_XXX + * + * @description: + * A list of constants used for the @hinting-engine property to select + * the hinting engine for CFF fonts. + * + * @values: + * FT_CFF_HINTING_FREETYPE :: + * Use the old FreeType hinting engine. + * + * FT_CFF_HINTING_ADOBE :: + * Use the hinting engine contributed by Adobe. + * + */ +#define FT_CFF_HINTING_FREETYPE 0 +#define FT_CFF_HINTING_ADOBE 1 + + + /************************************************************************** + * + * @property: + * no-stem-darkening[cff] + * + * @description: + * By default, the Adobe CFF engine darkens stems at smaller sizes, + * regardless of hinting, to enhance contrast. This feature requires + * a rendering system with proper gamma correction. Setting this + * property, stem darkening gets switched off. + * + * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. + * + * { + * FT_Library library; + * FT_Bool no_stem_darkening = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "no-stem-darkening", &no_stem_darkening ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + */ + + + /************************************************************************** + * + * @property: + * darkening-parameters[cff] + * + * @description: + * By default, the Adobe CFF engine darkens stems as follows (if the + * `no-stem-darkening' property isn't set): + * + * { + * stem width <= 0.5px: darkening amount = 0.4px + * stem width = 1px: darkening amount = 0.275px + * stem width = 1.667px: darkening amount = 0.275px + * stem width >= 2.333px: darkening amount = 0px + * } + * + * and piecewise linear in-between. At configuration time, these four + * control points can be set with the macro + * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'. At runtime, the control + * points can be changed using the `darkening-parameters' property, as + * the following example demonstrates. + * + * { + * FT_Library library; + * FT_Int darken_params[8] = { 500, 300, // x1, y1 + * 1000, 200, // x2, y2 + * 1500, 100, // x3, y3 + * 2000, 0 }; // x4, y4 + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "darkening-parameters", darken_params ); + * } + * + * The x~values give the stem width, and the y~values the darkening + * amount. The unit is 1000th of pixels. All coordinate values must be + * positive; the x~values must be monotonically increasing; the + * y~values must be monotonically decreasing and smaller than or + * equal to 500 (corresponding to half a pixel); the slope of each + * linear piece must be shallower than -1 (e.g., -.4). + * + * @note: + * This property can be used with @FT_Property_Get also. + * + */ + + /* */ + + +FT_END_HEADER + + +#endif /* FTCFFDRV_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftchapters.h b/foreign/freetype2/freetype/ftchapters.h new file mode 100644 index 0000000..ab43895 --- /dev/null +++ b/foreign/freetype2/freetype/ftchapters.h @@ -0,0 +1,135 @@ +/***************************************************************************/ +/* */ +/* This file defines the structure of the FreeType reference. */ +/* It is used by the python script that generates the HTML files. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* general_remarks */ +/* */ +/* <Title> */ +/* General Remarks */ +/* */ +/* <Sections> */ +/* header_inclusion */ +/* user_allocation */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* core_api */ +/* */ +/* <Title> */ +/* Core API */ +/* */ +/* <Sections> */ +/* version */ +/* basic_types */ +/* base_interface */ +/* glyph_variants */ +/* glyph_management */ +/* mac_specific */ +/* sizes_management */ +/* header_file_macros */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* format_specific */ +/* */ +/* <Title> */ +/* Format-Specific API */ +/* */ +/* <Sections> */ +/* multiple_masters */ +/* truetype_tables */ +/* type1_tables */ +/* sfnt_names */ +/* bdf_fonts */ +/* cid_fonts */ +/* pfr_fonts */ +/* winfnt_fonts */ +/* font_formats */ +/* gasp_table */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* module_specific */ +/* */ +/* <Title> */ +/* Controlling FreeType Modules */ +/* */ +/* <Sections> */ +/* auto_hinter */ +/* cff_driver */ +/* tt_driver */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* cache_subsystem */ +/* */ +/* <Title> */ +/* Cache Sub-System */ +/* */ +/* <Sections> */ +/* cache_subsystem */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* support_api */ +/* */ +/* <Title> */ +/* Support API */ +/* */ +/* <Sections> */ +/* computations */ +/* list_processing */ +/* outline_processing */ +/* quick_advance */ +/* bitmap_handling */ +/* raster */ +/* glyph_stroker */ +/* system_interface */ +/* module_management */ +/* gzip */ +/* lzw */ +/* bzip2 */ +/* lcd_filtering */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* error_codes */ +/* */ +/* <Title> */ +/* Error Codes */ +/* */ +/* <Sections> */ +/* error_enumerations */ +/* error_code_values */ +/* */ +/***************************************************************************/ diff --git a/foreign/freetype2/freetype/ftcid.h b/foreign/freetype2/freetype/ftcid.h new file mode 100644 index 0000000..140f2f8 --- /dev/null +++ b/foreign/freetype2/freetype/ftcid.h @@ -0,0 +1,168 @@ +/***************************************************************************/ +/* */ +/* ftcid.h */ +/* */ +/* FreeType API for accessing CID font information (specification). */ +/* */ +/* Copyright 2007-2016 by */ +/* Dereg Clegg and Michael Toftdal. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCID_H_ +#define FTCID_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* cid_fonts */ + /* */ + /* <Title> */ + /* CID Fonts */ + /* */ + /* <Abstract> */ + /* CID-keyed font specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of CID-keyed font specific */ + /* functions. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @function: + * FT_Get_CID_Registry_Ordering_Supplement + * + * @description: + * Retrieve the Registry/Ordering/Supplement triple (also known as the + * "R/O/S") from a CID-keyed font. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * registry :: + * The registry, as a C~string, owned by the face. + * + * ordering :: + * The ordering, as a C~string, owned by the face. + * + * supplement :: + * The supplement. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces, returning an error + * otherwise. + * + * @since: + * 2.3.6 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, + const char* *registry, + const char* *ordering, + FT_Int *supplement); + + + /********************************************************************** + * + * @function: + * FT_Get_CID_Is_Internally_CID_Keyed + * + * @description: + * Retrieve the type of the input face, CID keyed or not. In + * constrast to the @FT_IS_CID_KEYED macro this function returns + * successfully also for CID-keyed fonts in an SNFT wrapper. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * is_cid :: + * The type of the face as an @FT_Bool. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, + * returning an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, + FT_Bool *is_cid ); + + + /********************************************************************** + * + * @function: + * FT_Get_CID_From_Glyph_Index + * + * @description: + * Retrieve the CID of the input glyph index. + * + * @input: + * face :: + * A handle to the input face. + * + * glyph_index :: + * The input glyph index. + * + * @output: + * cid :: + * The CID as an @FT_UInt. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, + * returning an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_From_Glyph_Index( FT_Face face, + FT_UInt glyph_index, + FT_UInt *cid ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCID_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/fterrdef.h b/foreign/freetype2/freetype/fterrdef.h new file mode 100644 index 0000000..3f53dd5 --- /dev/null +++ b/foreign/freetype2/freetype/fterrdef.h @@ -0,0 +1,276 @@ +/***************************************************************************/ +/* */ +/* fterrdef.h */ +/* */ +/* FreeType error codes (specification). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* error_code_values */ + /* */ + /* <Title> */ + /* Error Code Values */ + /* */ + /* <Abstract> */ + /* All possible error codes returned by FreeType functions. */ + /* */ + /* <Description> */ + /* The list below is taken verbatim from the file `fterrdef.h' */ + /* (loaded automatically by including `FT_FREETYPE_H'). The first */ + /* argument of the `FT_ERROR_DEF_' macro is the error label; by */ + /* default, the prefix `FT_Err_' gets added so that you get error */ + /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */ + /* the error code, and the last argument an error string, which is not */ + /* used by FreeType. */ + /* */ + /* Within your application you should *only* use error names and */ + /* *never* its numeric values! The latter might (and actually do) */ + /* change in forthcoming FreeType versions. */ + /* */ + /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */ + /* See the `Error Enumerations' subsection how to automatically */ + /* generate a list of error strings. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Err_XXX */ + /* */ + /*************************************************************************/ + + /* generic errors */ + + FT_NOERRORDEF_( Ok, 0x00, + "no error" ) + + FT_ERRORDEF_( Cannot_Open_Resource, 0x01, + "cannot open resource" ) + FT_ERRORDEF_( Unknown_File_Format, 0x02, + "unknown file format" ) + FT_ERRORDEF_( Invalid_File_Format, 0x03, + "broken file" ) + FT_ERRORDEF_( Invalid_Version, 0x04, + "invalid FreeType version" ) + FT_ERRORDEF_( Lower_Module_Version, 0x05, + "module version is too low" ) + FT_ERRORDEF_( Invalid_Argument, 0x06, + "invalid argument" ) + FT_ERRORDEF_( Unimplemented_Feature, 0x07, + "unimplemented feature" ) + FT_ERRORDEF_( Invalid_Table, 0x08, + "broken table" ) + FT_ERRORDEF_( Invalid_Offset, 0x09, + "broken offset within table" ) + FT_ERRORDEF_( Array_Too_Large, 0x0A, + "array allocation size too large" ) + FT_ERRORDEF_( Missing_Module, 0x0B, + "missing module" ) + FT_ERRORDEF_( Missing_Property, 0x0C, + "missing property" ) + + /* glyph/character errors */ + + FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, + "invalid glyph index" ) + FT_ERRORDEF_( Invalid_Character_Code, 0x11, + "invalid character code" ) + FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, + "unsupported glyph image format" ) + FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, + "cannot render this glyph format" ) + FT_ERRORDEF_( Invalid_Outline, 0x14, + "invalid outline" ) + FT_ERRORDEF_( Invalid_Composite, 0x15, + "invalid composite glyph" ) + FT_ERRORDEF_( Too_Many_Hints, 0x16, + "too many hints" ) + FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, + "invalid pixel size" ) + + /* handle errors */ + + FT_ERRORDEF_( Invalid_Handle, 0x20, + "invalid object handle" ) + FT_ERRORDEF_( Invalid_Library_Handle, 0x21, + "invalid library handle" ) + FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, + "invalid module handle" ) + FT_ERRORDEF_( Invalid_Face_Handle, 0x23, + "invalid face handle" ) + FT_ERRORDEF_( Invalid_Size_Handle, 0x24, + "invalid size handle" ) + FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, + "invalid glyph slot handle" ) + FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, + "invalid charmap handle" ) + FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, + "invalid cache manager handle" ) + FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, + "invalid stream handle" ) + + /* driver errors */ + + FT_ERRORDEF_( Too_Many_Drivers, 0x30, + "too many modules" ) + FT_ERRORDEF_( Too_Many_Extensions, 0x31, + "too many extensions" ) + + /* memory errors */ + + FT_ERRORDEF_( Out_Of_Memory, 0x40, + "out of memory" ) + FT_ERRORDEF_( Unlisted_Object, 0x41, + "unlisted object" ) + + /* stream errors */ + + FT_ERRORDEF_( Cannot_Open_Stream, 0x51, + "cannot open stream" ) + FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, + "invalid stream seek" ) + FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, + "invalid stream skip" ) + FT_ERRORDEF_( Invalid_Stream_Read, 0x54, + "invalid stream read" ) + FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, + "invalid stream operation" ) + FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, + "invalid frame operation" ) + FT_ERRORDEF_( Nested_Frame_Access, 0x57, + "nested frame access" ) + FT_ERRORDEF_( Invalid_Frame_Read, 0x58, + "invalid frame read" ) + + /* raster errors */ + + FT_ERRORDEF_( Raster_Uninitialized, 0x60, + "raster uninitialized" ) + FT_ERRORDEF_( Raster_Corrupted, 0x61, + "raster corrupted" ) + FT_ERRORDEF_( Raster_Overflow, 0x62, + "raster overflow" ) + FT_ERRORDEF_( Raster_Negative_Height, 0x63, + "negative height while rastering" ) + + /* cache errors */ + + FT_ERRORDEF_( Too_Many_Caches, 0x70, + "too many registered caches" ) + + /* TrueType and SFNT errors */ + + FT_ERRORDEF_( Invalid_Opcode, 0x80, + "invalid opcode" ) + FT_ERRORDEF_( Too_Few_Arguments, 0x81, + "too few arguments" ) + FT_ERRORDEF_( Stack_Overflow, 0x82, + "stack overflow" ) + FT_ERRORDEF_( Code_Overflow, 0x83, + "code overflow" ) + FT_ERRORDEF_( Bad_Argument, 0x84, + "bad argument" ) + FT_ERRORDEF_( Divide_By_Zero, 0x85, + "division by zero" ) + FT_ERRORDEF_( Invalid_Reference, 0x86, + "invalid reference" ) + FT_ERRORDEF_( Debug_OpCode, 0x87, + "found debug opcode" ) + FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, + "found ENDF opcode in execution stream" ) + FT_ERRORDEF_( Nested_DEFS, 0x89, + "nested DEFS" ) + FT_ERRORDEF_( Invalid_CodeRange, 0x8A, + "invalid code range" ) + FT_ERRORDEF_( Execution_Too_Long, 0x8B, + "execution context too long" ) + FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, + "too many function definitions" ) + FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, + "too many instruction definitions" ) + FT_ERRORDEF_( Table_Missing, 0x8E, + "SFNT font table missing" ) + FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, + "horizontal header (hhea) table missing" ) + FT_ERRORDEF_( Locations_Missing, 0x90, + "locations (loca) table missing" ) + FT_ERRORDEF_( Name_Table_Missing, 0x91, + "name table missing" ) + FT_ERRORDEF_( CMap_Table_Missing, 0x92, + "character map (cmap) table missing" ) + FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, + "horizontal metrics (hmtx) table missing" ) + FT_ERRORDEF_( Post_Table_Missing, 0x94, + "PostScript (post) table missing" ) + FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, + "invalid horizontal metrics" ) + FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, + "invalid character map (cmap) format" ) + FT_ERRORDEF_( Invalid_PPem, 0x97, + "invalid ppem value" ) + FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, + "invalid vertical metrics" ) + FT_ERRORDEF_( Could_Not_Find_Context, 0x99, + "could not find context" ) + FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, + "invalid PostScript (post) table format" ) + FT_ERRORDEF_( Invalid_Post_Table, 0x9B, + "invalid PostScript (post) table" ) + + /* CFF, CID, and Type 1 errors */ + + FT_ERRORDEF_( Syntax_Error, 0xA0, + "opcode syntax error" ) + FT_ERRORDEF_( Stack_Underflow, 0xA1, + "argument stack underflow" ) + FT_ERRORDEF_( Ignore, 0xA2, + "ignore" ) + FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, + "no Unicode glyph name found" ) + FT_ERRORDEF_( Glyph_Too_Big, 0xA4, + "glyph too big for hinting" ) + + /* BDF errors */ + + FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, + "`STARTFONT' field missing" ) + FT_ERRORDEF_( Missing_Font_Field, 0xB1, + "`FONT' field missing" ) + FT_ERRORDEF_( Missing_Size_Field, 0xB2, + "`SIZE' field missing" ) + FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, + "`FONTBOUNDINGBOX' field missing" ) + FT_ERRORDEF_( Missing_Chars_Field, 0xB4, + "`CHARS' field missing" ) + FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, + "`STARTCHAR' field missing" ) + FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, + "`ENCODING' field missing" ) + FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, + "`BBX' field missing" ) + FT_ERRORDEF_( Bbx_Too_Big, 0xB8, + "`BBX' too big" ) + FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, + "Font header corrupted or missing fields" ) + FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, + "Font glyphs corrupted or missing fields" ) + + /* */ + + +/* END */ diff --git a/foreign/freetype2/freetype/fterrors.h b/foreign/freetype2/freetype/fterrors.h new file mode 100644 index 0000000..e15bfb0 --- /dev/null +++ b/foreign/freetype2/freetype/fterrors.h @@ -0,0 +1,226 @@ +/***************************************************************************/ +/* */ +/* fterrors.h */ +/* */ +/* FreeType error code handling (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* error_enumerations */ + /* */ + /* <Title> */ + /* Error Enumerations */ + /* */ + /* <Abstract> */ + /* How to handle errors and error strings. */ + /* */ + /* <Description> */ + /* The header file `fterrors.h' (which is automatically included by */ + /* `freetype.h' defines the handling of FreeType's enumeration */ + /* constants. It can also be used to generate error message strings */ + /* with a small macro trick explained below. */ + /* */ + /* *Error* *Formats* */ + /* */ + /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ + /* defined in `ftoption.h' in order to make the higher byte indicate */ + /* the module where the error has happened (this is not compatible */ + /* with standard builds of FreeType 2, however). See the file */ + /* `ftmoderr.h' for more details. */ + /* */ + /* *Error* *Message* *Strings* */ + /* */ + /* Error definitions are set up with special macros that allow client */ + /* applications to build a table of error message strings. The */ + /* strings are not included in a normal build of FreeType 2 to */ + /* save space (most client applications do not use them). */ + /* */ + /* To do so, you have to define the following macros before including */ + /* this file. */ + /* */ + /* { */ + /* FT_ERROR_START_LIST */ + /* } */ + /* */ + /* This macro is called before anything else to define the start of */ + /* the error list. It is followed by several FT_ERROR_DEF calls. */ + /* */ + /* { */ + /* FT_ERROR_DEF( e, v, s ) */ + /* } */ + /* */ + /* This macro is called to define one single error. `e' is the error */ + /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */ + /* numerical value, and `s' is the corresponding error string. */ + /* */ + /* { */ + /* FT_ERROR_END_LIST */ + /* } */ + /* */ + /* This macro ends the list. */ + /* */ + /* Additionally, you have to undefine `FTERRORS_H_' before #including */ + /* this file. */ + /* */ + /* Here is a simple example. */ + /* */ + /* { */ + /* #undef FTERRORS_H_ */ + /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ + /* #define FT_ERROR_START_LIST { */ + /* #define FT_ERROR_END_LIST { 0, NULL } }; */ + /* */ + /* const struct */ + /* { */ + /* int err_code; */ + /* const char* err_msg; */ + /* } ft_errors[] = */ + /* */ + /* #include FT_ERRORS_H */ + /* } */ + /* */ + /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */ + /* `FT_NOERRORDEF'; it is always zero. */ + /* */ + /*************************************************************************/ + + /* */ + + /* In previous FreeType versions we used `__FTERRORS_H__'. However, */ + /* using two successive underscores in a non-system symbol name */ + /* violates the C (and C++) standard, so it was changed to the */ + /* current form. In spite of this, we have to make */ + /* */ + /* #undefine __FTERRORS_H__ */ + /* */ + /* work for backwards compatibility. */ + /* */ +#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) ) +#define FTERRORS_H_ +#define __FTERRORS_H__ + + + /* include module base error codes */ +#include FT_MODULE_ERRORS_H + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + + + /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ + /* By default, we use `FT_Err_'. */ + /* */ +#ifndef FT_ERR_PREFIX +#define FT_ERR_PREFIX FT_Err_ +#endif + + + /* FT_ERR_BASE is used as the base for module-specific errors. */ + /* */ +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS + +#ifndef FT_ERR_BASE +#define FT_ERR_BASE FT_Mod_Err_Base +#endif + +#else + +#undef FT_ERR_BASE +#define FT_ERR_BASE 0 + +#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */ + + + /* If FT_ERRORDEF is not defined, we need to define a simple */ + /* enumeration type. */ + /* */ +#ifndef FT_ERRORDEF + +#define FT_ERRORDEF( e, v, s ) e = v, +#define FT_ERROR_START_LIST enum { +#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_ERRORDEF */ + + + /* this macro is used to define an error */ +#define FT_ERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) + + /* this is only used for <module>_Err_Ok, which must be 0! */ +#define FT_NOERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) + + +#ifdef FT_ERROR_START_LIST + FT_ERROR_START_LIST +#endif + + + /* now include the error codes */ +#include FT_ERROR_DEFINITIONS_H + + +#ifdef FT_ERROR_END_LIST + FT_ERROR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SIMPLE CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_ERROR_START_LIST +#undef FT_ERROR_END_LIST + +#undef FT_ERRORDEF +#undef FT_ERRORDEF_ +#undef FT_NOERRORDEF_ + +#undef FT_NEED_EXTERN_C +#undef FT_ERR_BASE + + /* FT_ERR_PREFIX is needed internally */ +#ifndef FT2_BUILD_LIBRARY +#undef FT_ERR_PREFIX +#endif + +#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftfntfmt.h b/foreign/freetype2/freetype/ftfntfmt.h new file mode 100644 index 0000000..bd42324 --- /dev/null +++ b/foreign/freetype2/freetype/ftfntfmt.h @@ -0,0 +1,95 @@ +/***************************************************************************/ +/* */ +/* ftfntfmt.h */ +/* */ +/* Support functions for font formats. */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTFNTFMT_H_ +#define FTFNTFMT_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* font_formats */ + /* */ + /* <Title> */ + /* Font Formats */ + /* */ + /* <Abstract> */ + /* Getting the font format. */ + /* */ + /* <Description> */ + /* The single function in this section can be used to get the font */ + /* format. Note that this information is not needed normally; */ + /* however, there are special cases (like in PDF devices) where it is */ + /* important to differentiate, in spite of FreeType's uniform API. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Font_Format */ + /* */ + /* <Description> */ + /* Return a string describing the format of a given face. Possible */ + /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ + /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ + /* */ + /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ + /* */ + /* <Input> */ + /* face :: */ + /* Input face handle. */ + /* */ + /* <Return> */ + /* Font format string. NULL in case of error. */ + /* */ + /* <Note> */ + /* A deprecated name for the same function is */ + /* `FT_Get_X11_Font_Format'. */ + /* */ + FT_EXPORT( const char* ) + FT_Get_Font_Format( FT_Face face ); + + + /* deprecated */ + FT_EXPORT( const char* ) + FT_Get_X11_Font_Format( FT_Face face ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTFNTFMT_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftgasp.h b/foreign/freetype2/freetype/ftgasp.h new file mode 100644 index 0000000..3f5b3bc --- /dev/null +++ b/foreign/freetype2/freetype/ftgasp.h @@ -0,0 +1,129 @@ +/***************************************************************************/ +/* */ +/* ftgasp.h */ +/* */ +/* Access of TrueType's `gasp' table (specification). */ +/* */ +/* Copyright 2007-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGASP_H_ +#define FTGASP_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + + /*************************************************************************** + * + * @section: + * gasp_table + * + * @title: + * Gasp Table + * + * @abstract: + * Retrieving TrueType `gasp' table entries. + * + * @description: + * The function @FT_Get_Gasp can be used to query a TrueType or OpenType + * font for specific entries in its `gasp' table, if any. This is + * mainly useful when implementing native TrueType hinting with the + * bytecode interpreter to duplicate the Windows text rendering results. + */ + + /************************************************************************* + * + * @enum: + * FT_GASP_XXX + * + * @description: + * A list of values and/or bit-flags returned by the @FT_Get_Gasp + * function. + * + * @values: + * FT_GASP_NO_TABLE :: + * This special value means that there is no GASP table in this face. + * It is up to the client to decide what to do. + * + * FT_GASP_DO_GRIDFIT :: + * Grid-fitting and hinting should be performed at the specified ppem. + * This *really* means TrueType bytecode interpretation. If this bit + * is not set, no hinting gets applied. + * + * FT_GASP_DO_GRAY :: + * Anti-aliased rendering should be performed at the specified ppem. + * If not set, do monochrome rendering. + * + * FT_GASP_SYMMETRIC_SMOOTHING :: + * If set, smoothing along multiple axes must be used with ClearType. + * + * FT_GASP_SYMMETRIC_GRIDFIT :: + * Grid-fitting must be used with ClearType's symmetric smoothing. + * + * @note: + * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be + * used for standard font rasterization only. Independently of that, + * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to + * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and + * `FT_GASP_DO_GRAY' are consequently ignored). + * + * `ClearType' is Microsoft's implementation of LCD rendering, partly + * protected by patents. + * + * @since: + * 2.3.0 + */ +#define FT_GASP_NO_TABLE -1 +#define FT_GASP_DO_GRIDFIT 0x01 +#define FT_GASP_DO_GRAY 0x02 +#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 +#define FT_GASP_SYMMETRIC_GRIDFIT 0x10 + + + /************************************************************************* + * + * @func: + * FT_Get_Gasp + * + * @description: + * Read the `gasp' table from a TrueType or OpenType font file and + * return the entry corresponding to a given character pixel size. + * + * @input: + * face :: The source face handle. + * ppem :: The vertical character pixel size. + * + * @return: + * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no + * `gasp' table in the face. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Int ) + FT_Get_Gasp( FT_Face face, + FT_UInt ppem ); + + /* */ + + +#endif /* FTGASP_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftglyph.h b/foreign/freetype2/freetype/ftglyph.h new file mode 100644 index 0000000..d9840a8 --- /dev/null +++ b/foreign/freetype2/freetype/ftglyph.h @@ -0,0 +1,605 @@ +/***************************************************************************/ +/* */ +/* ftglyph.h */ +/* */ +/* FreeType convenience functions to handle glyphs (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file contains the definition of several convenience functions */ + /* that can be used by client applications to easily retrieve glyph */ + /* bitmaps and outlines from a given face. */ + /* */ + /* These functions should be optional if you are writing a font server */ + /* or text layout engine on top of FreeType. However, they are pretty */ + /* handy for many other simple uses of the library. */ + /* */ + /*************************************************************************/ + + +#ifndef FTGLYPH_H_ +#define FTGLYPH_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* glyph_management */ + /* */ + /* <Title> */ + /* Glyph Management */ + /* */ + /* <Abstract> */ + /* Generic interface to manage individual glyph data. */ + /* */ + /* <Description> */ + /* This section contains definitions used to manage glyph data */ + /* through generic FT_Glyph objects. Each of them can contain a */ + /* bitmap, a vector outline, or even images in other formats. */ + /* */ + /*************************************************************************/ + + + /* forward declaration to a private type */ + typedef struct FT_Glyph_Class_ FT_Glyph_Class; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Glyph */ + /* */ + /* <Description> */ + /* Handle to an object used to model generic glyph images. It is a */ + /* pointer to the @FT_GlyphRec structure and can contain a glyph */ + /* bitmap or pointer. */ + /* */ + /* <Note> */ + /* Glyph objects are not owned by the library. You must thus release */ + /* them manually (through @FT_Done_Glyph) _before_ calling */ + /* @FT_Done_FreeType. */ + /* */ + typedef struct FT_GlyphRec_* FT_Glyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_GlyphRec */ + /* */ + /* <Description> */ + /* The root glyph structure contains a given glyph image plus its */ + /* advance width in 16.16 fixed-point format. */ + /* */ + /* <Fields> */ + /* library :: A handle to the FreeType library object. */ + /* */ + /* clazz :: A pointer to the glyph's class. Private. */ + /* */ + /* format :: The format of the glyph's image. */ + /* */ + /* advance :: A 16.16 vector that gives the glyph's advance width. */ + /* */ + typedef struct FT_GlyphRec_ + { + FT_Library library; + const FT_Glyph_Class* clazz; + FT_Glyph_Format format; + FT_Vector advance; + + } FT_GlyphRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_BitmapGlyph */ + /* */ + /* <Description> */ + /* A handle to an object used to model a bitmap glyph image. This is */ + /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ + /* */ + typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_BitmapGlyphRec */ + /* */ + /* <Description> */ + /* A structure used for bitmap glyph images. This really is a */ + /* `sub-class' of @FT_GlyphRec. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Glyph fields. */ + /* */ + /* left :: The left-side bearing, i.e., the horizontal distance */ + /* from the current pen position to the left border of the */ + /* glyph bitmap. */ + /* */ + /* top :: The top-side bearing, i.e., the vertical distance from */ + /* the current pen position to the top border of the glyph */ + /* bitmap. This distance is positive for upwards~y! */ + /* */ + /* bitmap :: A descriptor for the bitmap. */ + /* */ + /* <Note> */ + /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ + /* the bitmap's contents easily. */ + /* */ + /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ + /* and is thus created and destroyed with it. */ + /* */ + typedef struct FT_BitmapGlyphRec_ + { + FT_GlyphRec root; + FT_Int left; + FT_Int top; + FT_Bitmap bitmap; + + } FT_BitmapGlyphRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_OutlineGlyph */ + /* */ + /* <Description> */ + /* A handle to an object used to model an outline glyph image. This */ + /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ + /* */ + typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_OutlineGlyphRec */ + /* */ + /* <Description> */ + /* A structure used for outline (vectorial) glyph images. This */ + /* really is a `sub-class' of @FT_GlyphRec. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Glyph fields. */ + /* */ + /* outline :: A descriptor for the outline. */ + /* */ + /* <Note> */ + /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ + /* the outline's content easily. */ + /* */ + /* As the outline is extracted from a glyph slot, its coordinates are */ + /* expressed normally in 26.6 pixels, unless the flag */ + /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ + /* */ + /* The outline's tables are always owned by the object and are */ + /* destroyed with it. */ + /* */ + typedef struct FT_OutlineGlyphRec_ + { + FT_GlyphRec root; + FT_Outline outline; + + } FT_OutlineGlyphRec; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Glyph */ + /* */ + /* <Description> */ + /* A function used to extract a glyph image from a slot. Note that */ + /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ + /* */ + /* <Input> */ + /* slot :: A handle to the source glyph slot. */ + /* */ + /* <Output> */ + /* aglyph :: A handle to the glyph object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph( FT_GlyphSlot slot, + FT_Glyph *aglyph ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Copy */ + /* */ + /* <Description> */ + /* A function used to copy a glyph image. Note that the created */ + /* @FT_Glyph object must be released with @FT_Done_Glyph. */ + /* */ + /* <Input> */ + /* source :: A handle to the source glyph object. */ + /* */ + /* <Output> */ + /* target :: A handle to the target glyph object. 0~in case of */ + /* error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_Copy( FT_Glyph source, + FT_Glyph *target ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Transform */ + /* */ + /* <Description> */ + /* Transform a glyph image if its format is scalable. */ + /* */ + /* <InOut> */ + /* glyph :: A handle to the target glyph object. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to a 2x2 matrix to apply. */ + /* */ + /* delta :: A pointer to a 2d vector to apply. Coordinates are */ + /* expressed in 1/64th of a pixel. */ + /* */ + /* <Return> */ + /* FreeType error code (if not 0, the glyph format is not scalable). */ + /* */ + /* <Note> */ + /* The 2x2 transformation matrix is also applied to the glyph's */ + /* advance vector. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_Transform( FT_Glyph glyph, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Glyph_BBox_Mode */ + /* */ + /* <Description> */ + /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ + /* */ + /* <Values> */ + /* FT_GLYPH_BBOX_UNSCALED :: */ + /* Return unscaled font units. */ + /* */ + /* FT_GLYPH_BBOX_SUBPIXELS :: */ + /* Return unfitted 26.6 coordinates. */ + /* */ + /* FT_GLYPH_BBOX_GRIDFIT :: */ + /* Return grid-fitted 26.6 coordinates. */ + /* */ + /* FT_GLYPH_BBOX_TRUNCATE :: */ + /* Return coordinates in integer pixels. */ + /* */ + /* FT_GLYPH_BBOX_PIXELS :: */ + /* Return grid-fitted pixel coordinates. */ + /* */ + typedef enum FT_Glyph_BBox_Mode_ + { + FT_GLYPH_BBOX_UNSCALED = 0, + FT_GLYPH_BBOX_SUBPIXELS = 0, + FT_GLYPH_BBOX_GRIDFIT = 1, + FT_GLYPH_BBOX_TRUNCATE = 2, + FT_GLYPH_BBOX_PIXELS = 3 + + } FT_Glyph_BBox_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_BBox_Mode' values instead */ +#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED +#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS +#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT +#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE +#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Get_CBox */ + /* */ + /* <Description> */ + /* Return a glyph's `control box'. The control box encloses all the */ + /* outline's points, including Bézier control points. Though it */ + /* coincides with the exact bounding box for most glyphs, it can be */ + /* slightly larger in some situations (like when rotating an outline */ + /* that contains Bézier outside arcs). */ + /* */ + /* Computing the control box is very fast, while getting the bounding */ + /* box can take much more time as it needs to walk over all segments */ + /* and arcs in the outline. To get the latter, you can use the */ + /* `ftbbox' component, which is dedicated to this single task. */ + /* */ + /* <Input> */ + /* glyph :: A handle to the source glyph object. */ + /* */ + /* mode :: The mode that indicates how to interpret the returned */ + /* bounding box values. */ + /* */ + /* <Output> */ + /* acbox :: The glyph coordinate bounding box. Coordinates are */ + /* expressed in 1/64th of pixels if it is grid-fitted. */ + /* */ + /* <Note> */ + /* Coordinates are relative to the glyph origin, using the y~upwards */ + /* convention. */ + /* */ + /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ + /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ + /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ + /* is another name for this constant. */ + /* */ + /* If the font is tricky and the glyph has been loaded with */ + /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ + /* reasonable values for the CBox it is necessary to load the glyph */ + /* at a large ppem value (so that the hinting instructions can */ + /* properly shift and scale the subglyphs), then extracting the CBox, */ + /* which can be eventually converted back to font units. */ + /* */ + /* Note that the maximum coordinates are exclusive, which means that */ + /* one can compute the width and height of the glyph image (be it in */ + /* integer or 26.6 pixels) as: */ + /* */ + /* { */ + /* width = bbox.xMax - bbox.xMin; */ + /* height = bbox.yMax - bbox.yMin; */ + /* } */ + /* */ + /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ + /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ + /* which corresponds to: */ + /* */ + /* { */ + /* bbox.xMin = FLOOR(bbox.xMin); */ + /* bbox.yMin = FLOOR(bbox.yMin); */ + /* bbox.xMax = CEILING(bbox.xMax); */ + /* bbox.yMax = CEILING(bbox.yMax); */ + /* } */ + /* */ + /* To get the bbox in pixel coordinates, set `bbox_mode' to */ + /* @FT_GLYPH_BBOX_TRUNCATE. */ + /* */ + /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ + /* to @FT_GLYPH_BBOX_PIXELS. */ + /* */ + FT_EXPORT( void ) + FT_Glyph_Get_CBox( FT_Glyph glyph, + FT_UInt bbox_mode, + FT_BBox *acbox ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_To_Bitmap */ + /* */ + /* <Description> */ + /* Convert a given glyph object to a bitmap glyph object. */ + /* */ + /* <InOut> */ + /* the_glyph :: A pointer to a handle to the target glyph. */ + /* */ + /* <Input> */ + /* render_mode :: An enumeration that describes how the data is */ + /* rendered. */ + /* */ + /* origin :: A pointer to a vector used to translate the glyph */ + /* image before rendering. Can be~0 (if no */ + /* translation). The origin is expressed in */ + /* 26.6 pixels. */ + /* */ + /* destroy :: A boolean that indicates that the original glyph */ + /* image should be destroyed by this function. It is */ + /* never destroyed in case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function does nothing if the glyph format isn't scalable. */ + /* */ + /* The glyph image is translated with the `origin' vector before */ + /* rendering. */ + /* */ + /* The first parameter is a pointer to an @FT_Glyph handle, that will */ + /* be _replaced_ by this function (with newly allocated data). */ + /* Typically, you would use (omitting error handling): */ + /* */ + /* */ + /* { */ + /* FT_Glyph glyph; */ + /* FT_BitmapGlyph glyph_bitmap; */ + /* */ + /* */ + /* // load glyph */ + /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ + /* */ + /* // extract glyph image */ + /* error = FT_Get_Glyph( face->glyph, &glyph ); */ + /* */ + /* // convert to a bitmap (default render mode + destroying old) */ + /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ + /* { */ + /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ + /* 0, 1 ); */ + /* if ( error ) // `glyph' unchanged */ + /* ... */ + /* } */ + /* */ + /* // access bitmap content by typecasting */ + /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ + /* */ + /* // do funny stuff with it, like blitting/drawing */ + /* ... */ + /* */ + /* // discard glyph image (bitmap or not) */ + /* FT_Done_Glyph( glyph ); */ + /* } */ + /* */ + /* */ + /* Here another example, again without error handling: */ + /* */ + /* */ + /* { */ + /* FT_Glyph glyphs[MAX_GLYPHS] */ + /* */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ + /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* { */ + /* FT_Glyph bitmap = glyphs[idx]; */ + /* */ + /* */ + /* ... */ + /* */ + /* // after this call, `bitmap' no longer points into */ + /* // the `glyphs' array (and the old value isn't destroyed) */ + /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ + /* */ + /* ... */ + /* */ + /* FT_Done_Glyph( bitmap ); */ + /* } */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* FT_Done_Glyph( glyphs[idx] ); */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_Render_Mode render_mode, + FT_Vector* origin, + FT_Bool destroy ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Glyph */ + /* */ + /* <Description> */ + /* Destroy a given glyph. */ + /* */ + /* <Input> */ + /* glyph :: A handle to the target glyph object. */ + /* */ + FT_EXPORT( void ) + FT_Done_Glyph( FT_Glyph glyph ); + + /* */ + + + /* other helpful functions */ + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Matrix_Multiply */ + /* */ + /* <Description> */ + /* Perform the matrix operation `b = a*b'. */ + /* */ + /* <Input> */ + /* a :: A pointer to matrix `a'. */ + /* */ + /* <InOut> */ + /* b :: A pointer to matrix `b'. */ + /* */ + /* <Note> */ + /* The result is undefined if either `a' or `b' is zero. */ + /* */ + FT_EXPORT( void ) + FT_Matrix_Multiply( const FT_Matrix* a, + FT_Matrix* b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Matrix_Invert */ + /* */ + /* <Description> */ + /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ + /* */ + /* <InOut> */ + /* matrix :: A pointer to the target matrix. Remains untouched in */ + /* case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Matrix_Invert( FT_Matrix* matrix ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGLYPH_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/ftgxval.h b/foreign/freetype2/freetype/ftgxval.h new file mode 100644 index 0000000..a58e86a --- /dev/null +++ b/foreign/freetype2/freetype/ftgxval.h @@ -0,0 +1,357 @@ +/***************************************************************************/ +/* */ +/* ftgxval.h */ +/* */ +/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ +/* */ +/* Copyright 2004-2016 by */ +/* Masatake YAMATO, Redhat K.K, */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGXVAL_H_ +#define FTGXVAL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* gx_validation */ + /* */ + /* <Title> */ + /* TrueTypeGX/AAT Validation */ + /* */ + /* <Abstract> */ + /* An API to validate TrueTypeGX/AAT tables. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions to validate */ + /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ + /* trak, prop, lcar). */ + /* */ + /* <Order> */ + /* FT_TrueTypeGX_Validate */ + /* FT_TrueTypeGX_Free */ + /* */ + /* FT_ClassicKern_Validate */ + /* FT_ClassicKern_Free */ + /* */ + /* FT_VALIDATE_GX_LENGTH */ + /* FT_VALIDATE_GXXXX */ + /* FT_VALIDATE_CKERNXXX */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* */ + /* Warning: Use FT_VALIDATE_XXX to validate a table. */ + /* Following definitions are for gxvalid developers. */ + /* */ + /* */ + /*************************************************************************/ + +#define FT_VALIDATE_feat_INDEX 0 +#define FT_VALIDATE_mort_INDEX 1 +#define FT_VALIDATE_morx_INDEX 2 +#define FT_VALIDATE_bsln_INDEX 3 +#define FT_VALIDATE_just_INDEX 4 +#define FT_VALIDATE_kern_INDEX 5 +#define FT_VALIDATE_opbd_INDEX 6 +#define FT_VALIDATE_trak_INDEX 7 +#define FT_VALIDATE_prop_INDEX 8 +#define FT_VALIDATE_lcar_INDEX 9 +#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX + + + /************************************************************************* + * + * @macro: + * FT_VALIDATE_GX_LENGTH + * + * @description: + * The number of tables checked in this module. Use it as a parameter + * for the `table-length' argument of function @FT_TrueTypeGX_Validate. + */ +#define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1) + + /* */ + + /* Up to 0x1000 is used by otvalid. + Ox2xxx is reserved for feature OT extension. */ +#define FT_VALIDATE_GX_START 0x4000 +#define FT_VALIDATE_GX_BITFIELD( tag ) \ + ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_GXXXX + * + * @description: + * A list of bit-field constants used with @FT_TrueTypeGX_Validate to + * indicate which TrueTypeGX/AAT Type tables should be validated. + * + * @values: + * FT_VALIDATE_feat :: + * Validate `feat' table. + * + * FT_VALIDATE_mort :: + * Validate `mort' table. + * + * FT_VALIDATE_morx :: + * Validate `morx' table. + * + * FT_VALIDATE_bsln :: + * Validate `bsln' table. + * + * FT_VALIDATE_just :: + * Validate `just' table. + * + * FT_VALIDATE_kern :: + * Validate `kern' table. + * + * FT_VALIDATE_opbd :: + * Validate `opbd' table. + * + * FT_VALIDATE_trak :: + * Validate `trak' table. + * + * FT_VALIDATE_prop :: + * Validate `prop' table. + * + * FT_VALIDATE_lcar :: + * Validate `lcar' table. + * + * FT_VALIDATE_GX :: + * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, + * opbd, trak, prop and lcar). + * + */ + +#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) +#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) +#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) +#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) +#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) +#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) +#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) +#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) +#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) +#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) + +#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ + FT_VALIDATE_mort | \ + FT_VALIDATE_morx | \ + FT_VALIDATE_bsln | \ + FT_VALIDATE_just | \ + FT_VALIDATE_kern | \ + FT_VALIDATE_opbd | \ + FT_VALIDATE_trak | \ + FT_VALIDATE_prop | \ + FT_VALIDATE_lcar ) + + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Validate + * + * @description: + * Validate various TrueTypeGX tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without + * error checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_GXXXX for possible values. + * + * table_length :: + * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH + * should be passed. + * + * @output: + * tables :: + * The array where all validated sfnt tables are stored. + * The array itself must be allocated by a client. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with TrueTypeGX fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the buffers pointed to by + * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value + * indicates that the table either doesn't exist in the font, the + * application hasn't asked for validation, or the validator doesn't have + * the ability to validate the sfnt table. + */ + FT_EXPORT( FT_Error ) + FT_TrueTypeGX_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Free + * + * @description: + * Free the buffer allocated by TrueTypeGX validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer allocated by + * @FT_TrueTypeGX_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_TrueTypeGX_Validate only. + */ + FT_EXPORT( void ) + FT_TrueTypeGX_Free( FT_Face face, + FT_Bytes table ); + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_CKERNXXX + * + * @description: + * A list of bit-field constants used with @FT_ClassicKern_Validate + * to indicate the classic kern dialect or dialects. If the selected + * type doesn't fit, @FT_ClassicKern_Validate regards the table as + * invalid. + * + * @values: + * FT_VALIDATE_MS :: + * Handle the `kern' table as a classic Microsoft kern table. + * + * FT_VALIDATE_APPLE :: + * Handle the `kern' table as a classic Apple kern table. + * + * FT_VALIDATE_CKERN :: + * Handle the `kern' as either classic Apple or Microsoft kern table. + */ +#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) +#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) + +#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) + + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Validate + * + * @description: + * Validate classic (16-bit format) kern table to assure that the offsets + * and indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both + * the new 32-bit format and the classic 16-bit format, while + * FT_ClassicKern_Validate only supports the classic 16-bit format. + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the dialect to be validated. See + * @FT_VALIDATE_CKERNXXX for possible values. + * + * @output: + * ckern_table :: + * A pointer to the kern table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * After use, the application should deallocate the buffers pointed to by + * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value + * indicates that the table doesn't exist in the font. + */ + FT_EXPORT( FT_Error ) + FT_ClassicKern_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *ckern_table ); + + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Free + * + * @description: + * Free the buffer allocated by classic Kern validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_ClassicKern_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_ClassicKern_Validate only. + */ + FT_EXPORT( void ) + FT_ClassicKern_Free( FT_Face face, + FT_Bytes table ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGXVAL_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftgzip.h b/foreign/freetype2/freetype/ftgzip.h new file mode 100644 index 0000000..9e658b0 --- /dev/null +++ b/foreign/freetype2/freetype/ftgzip.h @@ -0,0 +1,148 @@ +/***************************************************************************/ +/* */ +/* ftgzip.h */ +/* */ +/* Gzip-compressed stream support. */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGZIP_H_ +#define FTGZIP_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* gzip */ + /* */ + /* <Title> */ + /* GZIP Streams */ + /* */ + /* <Abstract> */ + /* Using gzip-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Gzip-specific functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************ + * + * @function: + * FT_Stream_OpenGzip + * + * @description: + * Open a new stream to parse gzip-compressed font files. This is + * mainly used to support the compressed `*.pcf.gz' fonts that come + * with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, gzip compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a gzipped stream from + * it and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with zlib support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenGzip( FT_Stream stream, + FT_Stream source ); + + + /************************************************************************ + * + * @function: + * FT_Gzip_Uncompress + * + * @description: + * Decompress a zipped input buffer into an output buffer. This function + * is modeled after zlib's `uncompress' function. + * + * @input: + * memory :: + * A FreeType memory handle. + * + * input :: + * The input buffer. + * + * input_len :: + * The length of the input buffer. + * + * @output: + * output:: + * The output buffer. + * + * @inout: + * output_len :: + * Before calling the function, this is the the total size of the + * output buffer, which must be large enough to hold the entire + * uncompressed data (so the size of the uncompressed data must be + * known in advance). After calling the function, `output_len' is the + * size of the used data in `output'. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with zlib support. + */ + FT_EXPORT( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGZIP_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftimage.h b/foreign/freetype2/freetype/ftimage.h new file mode 100644 index 0000000..1d557c9 --- /dev/null +++ b/foreign/freetype2/freetype/ftimage.h @@ -0,0 +1,1214 @@ +/***************************************************************************/ +/* */ +/* ftimage.h */ +/* */ +/* FreeType glyph image formats and default raster interface */ +/* (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Note: A `raster' is simply a scan-line converter, used to render */ + /* FT_Outlines into FT_Bitmaps. */ + /* */ + /*************************************************************************/ + + +#ifndef FTIMAGE_H_ +#define FTIMAGE_H_ + + + /* STANDALONE_ is from ftgrays.c */ +#ifndef STANDALONE_ +#include <ft2build.h> +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Pos */ + /* */ + /* <Description> */ + /* The type FT_Pos is used to store vectorial coordinates. Depending */ + /* on the context, these can represent distances in integer font */ + /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ + /* */ + typedef signed long FT_Pos; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Vector */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2D vector; coordinates are of */ + /* the FT_Pos type. */ + /* */ + /* <Fields> */ + /* x :: The horizontal coordinate. */ + /* y :: The vertical coordinate. */ + /* */ + typedef struct FT_Vector_ + { + FT_Pos x; + FT_Pos y; + + } FT_Vector; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_BBox */ + /* */ + /* <Description> */ + /* A structure used to hold an outline's bounding box, i.e., the */ + /* coordinates of its extrema in the horizontal and vertical */ + /* directions. */ + /* */ + /* <Fields> */ + /* xMin :: The horizontal minimum (left-most). */ + /* */ + /* yMin :: The vertical minimum (bottom-most). */ + /* */ + /* xMax :: The horizontal maximum (right-most). */ + /* */ + /* yMax :: The vertical maximum (top-most). */ + /* */ + /* <Note> */ + /* The bounding box is specified with the coordinates of the lower */ + /* left and the upper right corner. In PostScript, those values are */ + /* often called (llx,lly) and (urx,ury), respectively. */ + /* */ + /* If `yMin' is negative, this value gives the glyph's descender. */ + /* Otherwise, the glyph doesn't descend below the baseline. */ + /* Similarly, if `ymax' is positive, this value gives the glyph's */ + /* ascender. */ + /* */ + /* `xMin' gives the horizontal distance from the glyph's origin to */ + /* the left edge of the glyph's bounding box. If `xMin' is negative, */ + /* the glyph extends to the left of the origin. */ + /* */ + typedef struct FT_BBox_ + { + FT_Pos xMin, yMin; + FT_Pos xMax, yMax; + + } FT_BBox; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Pixel_Mode */ + /* */ + /* <Description> */ + /* An enumeration type used to describe the format of pixels in a */ + /* given bitmap. Note that additional formats may be added in the */ + /* future. */ + /* */ + /* <Values> */ + /* FT_PIXEL_MODE_NONE :: */ + /* Value~0 is reserved. */ + /* */ + /* FT_PIXEL_MODE_MONO :: */ + /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ + /* are stored in most-significant order (MSB), which means that */ + /* the left-most pixel in a byte has value 128. */ + /* */ + /* FT_PIXEL_MODE_GRAY :: */ + /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ + /* images. Each pixel is stored in one byte. Note that the number */ + /* of `gray' levels is stored in the `num_grays' field of the */ + /* @FT_Bitmap structure (it generally is 256). */ + /* */ + /* FT_PIXEL_MODE_GRAY2 :: */ + /* A 2-bit per pixel bitmap, used to represent embedded */ + /* anti-aliased bitmaps in font files according to the OpenType */ + /* specification. We haven't found a single font using this */ + /* format, however. */ + /* */ + /* FT_PIXEL_MODE_GRAY4 :: */ + /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* FT_PIXEL_MODE_LCD :: */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on LCD displays; the bitmap is three times */ + /* wider than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD. */ + /* */ + /* FT_PIXEL_MODE_LCD_V :: */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on rotated LCD displays; the bitmap is three */ + /* times taller than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD_V. */ + /* */ + /* FT_PIXEL_MODE_BGRA :: */ + /* An image with four 8-bit channels per pixel, representing a */ + /* color image (such as emoticons) with alpha channel. For each */ + /* pixel, the format is BGRA, which means, the blue channel comes */ + /* first in memory. The color channels are pre-multiplied and in */ + /* the sRGB colorspace. For example, full red at half-translucent */ + /* opacity will be represented as `00,00,80,80', not `00,00,FF,80'. */ + /* See also @FT_LOAD_COLOR. */ + /* */ + typedef enum FT_Pixel_Mode_ + { + FT_PIXEL_MODE_NONE = 0, + FT_PIXEL_MODE_MONO, + FT_PIXEL_MODE_GRAY, + FT_PIXEL_MODE_GRAY2, + FT_PIXEL_MODE_GRAY4, + FT_PIXEL_MODE_LCD, + FT_PIXEL_MODE_LCD_V, + FT_PIXEL_MODE_BGRA, + + FT_PIXEL_MODE_MAX /* do not remove */ + + } FT_Pixel_Mode; + + + /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */ + /* values instead. */ +#define ft_pixel_mode_none FT_PIXEL_MODE_NONE +#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO +#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY +#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 +#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Bitmap */ + /* */ + /* <Description> */ + /* A structure used to describe a bitmap or pixmap to the raster. */ + /* Note that we now manage pixmaps of various depths through the */ + /* `pixel_mode' field. */ + /* */ + /* <Fields> */ + /* rows :: The number of bitmap rows. */ + /* */ + /* width :: The number of pixels in bitmap row. */ + /* */ + /* pitch :: The pitch's absolute value is the number of bytes */ + /* taken by one bitmap row, including padding. */ + /* However, the pitch is positive when the bitmap has */ + /* a `down' flow, and negative when it has an `up' */ + /* flow. In all cases, the pitch is an offset to add */ + /* to a bitmap pointer in order to go down one row. */ + /* */ + /* Note that `padding' means the alignment of a */ + /* bitmap to a byte border, and FreeType functions */ + /* normally align to the smallest possible integer */ + /* value. */ + /* */ + /* For the B/W rasterizer, `pitch' is always an even */ + /* number. */ + /* */ + /* To change the pitch of a bitmap (say, to make it a */ + /* multiple of 4), use @FT_Bitmap_Convert. */ + /* Alternatively, you might use callback functions to */ + /* directly render to the application's surface; see */ + /* the file `example2.cpp' in the tutorial for a */ + /* demonstration. */ + /* */ + /* buffer :: A typeless pointer to the bitmap buffer. This */ + /* value should be aligned on 32-bit boundaries in */ + /* most cases. */ + /* */ + /* num_grays :: This field is only used with */ + /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ + /* levels used in the bitmap. */ + /* */ + /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ + /* See @FT_Pixel_Mode for possible values. */ + /* */ + /* palette_mode :: This field is intended for paletted pixel modes; */ + /* it indicates how the palette is stored. Not */ + /* used currently. */ + /* */ + /* palette :: A typeless pointer to the bitmap palette; this */ + /* field is intended for paletted pixel modes. Not */ + /* used currently. */ + /* */ + typedef struct FT_Bitmap_ + { + unsigned int rows; + unsigned int width; + int pitch; + unsigned char* buffer; + unsigned short num_grays; + unsigned char pixel_mode; + unsigned char palette_mode; + void* palette; + + } FT_Bitmap; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Outline */ + /* */ + /* <Description> */ + /* This structure is used to describe an outline to the scan-line */ + /* converter. */ + /* */ + /* <Fields> */ + /* n_contours :: The number of contours in the outline. */ + /* */ + /* n_points :: The number of points in the outline. */ + /* */ + /* points :: A pointer to an array of `n_points' @FT_Vector */ + /* elements, giving the outline's point coordinates. */ + /* */ + /* tags :: A pointer to an array of `n_points' chars, giving */ + /* each outline point's type. */ + /* */ + /* If bit~0 is unset, the point is `off' the curve, */ + /* i.e., a Bézier control point, while it is `on' if */ + /* set. */ + /* */ + /* Bit~1 is meaningful for `off' points only. If set, */ + /* it indicates a third-order Bézier arc control point; */ + /* and a second-order control point if unset. */ + /* */ + /* If bit~2 is set, bits 5-7 contain the drop-out mode */ + /* (as defined in the OpenType specification; the value */ + /* is the same as the argument to the SCANMODE */ + /* instruction). */ + /* */ + /* Bits 3 and~4 are reserved for internal purposes. */ + /* */ + /* contours :: An array of `n_contours' shorts, giving the end */ + /* point of each contour within the outline. For */ + /* example, the first contour is defined by the points */ + /* `0' to `contours[0]', the second one is defined by */ + /* the points `contours[0]+1' to `contours[1]', etc. */ + /* */ + /* flags :: A set of bit flags used to characterize the outline */ + /* and give hints to the scan-converter and hinter on */ + /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */ + /* */ + /* <Note> */ + /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ + /* first point of each contour. The drop-out mode as given with */ + /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ + /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ + /* */ + typedef struct FT_Outline_ + { + short n_contours; /* number of contours in glyph */ + short n_points; /* number of points in the glyph */ + + FT_Vector* points; /* the outline's points */ + char* tags; /* the points flags */ + short* contours; /* the contour end points */ + + int flags; /* outline masks */ + + } FT_Outline; + + /* */ + + /* Following limits must be consistent with */ + /* FT_Outline.{n_contours,n_points} */ +#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX +#define FT_OUTLINE_POINTS_MAX SHRT_MAX + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_OUTLINE_XXX */ + /* */ + /* <Description> */ + /* A list of bit-field constants use for the flags in an outline's */ + /* `flags' field. */ + /* */ + /* <Values> */ + /* FT_OUTLINE_NONE :: */ + /* Value~0 is reserved. */ + /* */ + /* FT_OUTLINE_OWNER :: */ + /* If set, this flag indicates that the outline's field arrays */ + /* (i.e., `points', `flags', and `contours') are `owned' by the */ + /* outline object, and should thus be freed when it is destroyed. */ + /* */ + /* FT_OUTLINE_EVEN_ODD_FILL :: */ + /* By default, outlines are filled using the non-zero winding rule. */ + /* If set to 1, the outline will be filled using the even-odd fill */ + /* rule (only works with the smooth rasterizer). */ + /* */ + /* FT_OUTLINE_REVERSE_FILL :: */ + /* By default, outside contours of an outline are oriented in */ + /* clock-wise direction, as defined in the TrueType specification. */ + /* This flag is set if the outline uses the opposite direction */ + /* (typically for Type~1 fonts). This flag is ignored by the scan */ + /* converter. */ + /* */ + /* FT_OUTLINE_IGNORE_DROPOUTS :: */ + /* By default, the scan converter will try to detect drop-outs in */ + /* an outline and correct the glyph bitmap to ensure consistent */ + /* shape continuity. If set, this flag hints the scan-line */ + /* converter to ignore such cases. See below for more information. */ + /* */ + /* FT_OUTLINE_SMART_DROPOUTS :: */ + /* Select smart dropout control. If unset, use simple dropout */ + /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ + /* below for more information. */ + /* */ + /* FT_OUTLINE_INCLUDE_STUBS :: */ + /* If set, turn pixels on for `stubs', otherwise exclude them. */ + /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ + /* more information. */ + /* */ + /* FT_OUTLINE_HIGH_PRECISION :: */ + /* This flag indicates that the scan-line converter should try to */ + /* convert this outline to bitmaps with the highest possible */ + /* quality. It is typically set for small character sizes. Note */ + /* that this is only a hint that might be completely ignored by a */ + /* given scan-converter. */ + /* */ + /* FT_OUTLINE_SINGLE_PASS :: */ + /* This flag is set to force a given scan-converter to only use a */ + /* single pass over the outline to render a bitmap glyph image. */ + /* Normally, it is set for very large character sizes. It is only */ + /* a hint that might be completely ignored by a given */ + /* scan-converter. */ + /* */ + /* <Note> */ + /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ + /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ + /* rasterizer. */ + /* */ + /* There exists a second mechanism to pass the drop-out mode to the */ + /* B/W rasterizer; see the `tags' field in @FT_Outline. */ + /* */ + /* Please refer to the description of the `SCANTYPE' instruction in */ + /* the OpenType specification (in file `ttinst1.doc') how simple */ + /* drop-outs, smart drop-outs, and stubs are defined. */ + /* */ +#define FT_OUTLINE_NONE 0x0 +#define FT_OUTLINE_OWNER 0x1 +#define FT_OUTLINE_EVEN_ODD_FILL 0x2 +#define FT_OUTLINE_REVERSE_FILL 0x4 +#define FT_OUTLINE_IGNORE_DROPOUTS 0x8 +#define FT_OUTLINE_SMART_DROPOUTS 0x10 +#define FT_OUTLINE_INCLUDE_STUBS 0x20 + +#define FT_OUTLINE_HIGH_PRECISION 0x100 +#define FT_OUTLINE_SINGLE_PASS 0x200 + + + /* these constants are deprecated; use the corresponding */ + /* `FT_OUTLINE_XXX' values instead */ +#define ft_outline_none FT_OUTLINE_NONE +#define ft_outline_owner FT_OUTLINE_OWNER +#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL +#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL +#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS +#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION +#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS + + /* */ + +#define FT_CURVE_TAG( flag ) ( flag & 3 ) + +#define FT_CURVE_TAG_ON 1 +#define FT_CURVE_TAG_CONIC 0 +#define FT_CURVE_TAG_CUBIC 2 + +#define FT_CURVE_TAG_HAS_SCANMODE 4 + +#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ + +#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ + FT_CURVE_TAG_TOUCH_Y ) + +#define FT_Curve_Tag_On FT_CURVE_TAG_ON +#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC +#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC +#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X +#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_MoveToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `move */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `move to' is emitted to start a new contour in an outline. */ + /* */ + /* <Input> */ + /* to :: A pointer to the target point of the `move to'. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_MoveToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_LineToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `line */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `line to' is emitted to indicate a segment in the outline. */ + /* */ + /* <Input> */ + /* to :: A pointer to the target point of the `line to'. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_LineToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_LineTo_Func FT_Outline_LineToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_ConicToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `conic */ + /* to' function during outline walking or decomposition. */ + /* */ + /* A `conic to' is emitted to indicate a second-order Bézier arc in */ + /* the outline. */ + /* */ + /* <Input> */ + /* control :: An intermediate control point between the last position */ + /* and the new target in `to'. */ + /* */ + /* to :: A pointer to the target end point of the conic arc. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_ConicToFunc)( const FT_Vector* control, + const FT_Vector* to, + void* user ); + +#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_CubicToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `cubic */ + /* to' function during outline walking or decomposition. */ + /* */ + /* A `cubic to' is emitted to indicate a third-order Bézier arc. */ + /* */ + /* <Input> */ + /* control1 :: A pointer to the first Bézier control point. */ + /* */ + /* control2 :: A pointer to the second Bézier control point. */ + /* */ + /* to :: A pointer to the target end point. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_CubicToFunc)( const FT_Vector* control1, + const FT_Vector* control2, + const FT_Vector* to, + void* user ); + +#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Outline_Funcs */ + /* */ + /* <Description> */ + /* A structure to hold various function pointers used during outline */ + /* decomposition in order to emit segments, conic, and cubic Béziers. */ + /* */ + /* <Fields> */ + /* move_to :: The `move to' emitter. */ + /* */ + /* line_to :: The segment emitter. */ + /* */ + /* conic_to :: The second-order Bézier arc emitter. */ + /* */ + /* cubic_to :: The third-order Bézier arc emitter. */ + /* */ + /* shift :: The shift that is applied to coordinates before they */ + /* are sent to the emitter. */ + /* */ + /* delta :: The delta that is applied to coordinates before they */ + /* are sent to the emitter, but after the shift. */ + /* */ + /* <Note> */ + /* The point coordinates sent to the emitters are the transformed */ + /* version of the original coordinates (this is important for high */ + /* accuracy during scan-conversion). The transformation is simple: */ + /* */ + /* { */ + /* x' = (x << shift) - delta */ + /* y' = (x << shift) - delta */ + /* } */ + /* */ + /* Set the values of `shift' and `delta' to~0 to get the original */ + /* point coordinates. */ + /* */ + typedef struct FT_Outline_Funcs_ + { + FT_Outline_MoveToFunc move_to; + FT_Outline_LineToFunc line_to; + FT_Outline_ConicToFunc conic_to; + FT_Outline_CubicToFunc cubic_to; + + int shift; + FT_Pos delta; + + } FT_Outline_Funcs; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_IMAGE_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags to an unsigned long type. */ + /* */ + /* <Note> */ + /* Since many 16-bit compilers don't like 32-bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* { */ + /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ + /* } */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ +#ifndef FT_IMAGE_TAG +#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ + value = ( ( (unsigned long)_x1 << 24 ) | \ + ( (unsigned long)_x2 << 16 ) | \ + ( (unsigned long)_x3 << 8 ) | \ + (unsigned long)_x4 ) +#endif /* FT_IMAGE_TAG */ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Glyph_Format */ + /* */ + /* <Description> */ + /* An enumeration type used to describe the format of a given glyph */ + /* image. Note that this version of FreeType only supports two image */ + /* formats, even though future font drivers will be able to register */ + /* their own format. */ + /* */ + /* <Values> */ + /* FT_GLYPH_FORMAT_NONE :: */ + /* The value~0 is reserved. */ + /* */ + /* FT_GLYPH_FORMAT_COMPOSITE :: */ + /* The glyph image is a composite of several other images. This */ + /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ + /* report compound glyphs (like accented characters). */ + /* */ + /* FT_GLYPH_FORMAT_BITMAP :: */ + /* The glyph image is a bitmap, and can be described as an */ + /* @FT_Bitmap. You generally need to access the `bitmap' field of */ + /* the @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_OUTLINE :: */ + /* The glyph image is a vectorial outline made of line segments */ + /* and Bézier arcs; it can be described as an @FT_Outline; you */ + /* generally want to access the `outline' field of the */ + /* @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_PLOTTER :: */ + /* The glyph image is a vectorial path with no inside and outside */ + /* contours. Some Type~1 fonts, like those in the Hershey family, */ + /* contain glyphs in this format. These are described as */ + /* @FT_Outline, but FreeType isn't currently capable of rendering */ + /* them correctly. */ + /* */ + typedef enum FT_Glyph_Format_ + { + FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + + FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) + + } FT_Glyph_Format; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_Format' values instead. */ +#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE +#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE +#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP +#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE +#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** R A S T E R D E F I N I T I O N S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* A raster is a scan converter, in charge of rendering an outline into */ + /* a a bitmap. This section contains the public API for rasters. */ + /* */ + /* Note that in FreeType 2, all rasters are now encapsulated within */ + /* specific modules called `renderers'. See `ftrender.h' for more */ + /* details on renderers. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* raster */ + /* */ + /* <Title> */ + /* Scanline Converter */ + /* */ + /* <Abstract> */ + /* How vectorial outlines are converted into bitmaps and pixmaps. */ + /* */ + /* <Description> */ + /* This section contains technical definitions. */ + /* */ + /* <Order> */ + /* FT_Raster */ + /* FT_Span */ + /* FT_SpanFunc */ + /* */ + /* FT_Raster_Params */ + /* FT_RASTER_FLAG_XXX */ + /* */ + /* FT_Raster_NewFunc */ + /* FT_Raster_DoneFunc */ + /* FT_Raster_ResetFunc */ + /* FT_Raster_SetModeFunc */ + /* FT_Raster_RenderFunc */ + /* FT_Raster_Funcs */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Raster */ + /* */ + /* <Description> */ + /* An opaque handle (pointer) to a raster object. Each object can be */ + /* used independently to convert an outline into a bitmap or pixmap. */ + /* */ + typedef struct FT_RasterRec_* FT_Raster; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Span */ + /* */ + /* <Description> */ + /* A structure used to model a single span of gray pixels when */ + /* rendering an anti-aliased bitmap. */ + /* */ + /* <Fields> */ + /* x :: The span's horizontal start position. */ + /* */ + /* len :: The span's length in pixels. */ + /* */ + /* coverage :: The span color/coverage, ranging from 0 (background) */ + /* to 255 (foreground). */ + /* */ + /* <Note> */ + /* This structure is used by the span drawing callback type named */ + /* @FT_SpanFunc that takes the y~coordinate of the span as a */ + /* parameter. */ + /* */ + /* The coverage value is always between 0 and 255. If you want less */ + /* gray values, the callback function has to reduce them. */ + /* */ + typedef struct FT_Span_ + { + short x; + unsigned short len; + unsigned char coverage; + + } FT_Span; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_SpanFunc */ + /* */ + /* <Description> */ + /* A function used as a call-back by the anti-aliased renderer in */ + /* order to let client applications draw themselves the gray pixel */ + /* spans on each scan line. */ + /* */ + /* <Input> */ + /* y :: The scanline's y~coordinate. */ + /* */ + /* count :: The number of spans to draw on this scanline. */ + /* */ + /* spans :: A table of `count' spans to draw on the scanline. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* <Note> */ + /* This callback allows client applications to directly render the */ + /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ + /* */ + /* This can be used to write anti-aliased outlines directly to a */ + /* given background bitmap, and even perform translucency. */ + /* */ + /* Note that the `count' field cannot be greater than a fixed value */ + /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */ + /* `ftoption.h'. By default, this value is set to~32, which means */ + /* that if there are more than 32~spans on a given scanline, the */ + /* callback is called several times with the same `y' parameter in */ + /* order to draw all callbacks. */ + /* */ + /* Otherwise, the callback is only called once per scan-line, and */ + /* only for those scanlines that do have `gray' pixels on them. */ + /* */ + typedef void + (*FT_SpanFunc)( int y, + int count, + const FT_Span* spans, + void* user ); + +#define FT_Raster_Span_Func FT_SpanFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_BitTest_Func */ + /* */ + /* <Description> */ + /* Deprecated, unimplemented. */ + /* */ + typedef int + (*FT_Raster_BitTest_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_BitSet_Func */ + /* */ + /* <Description> */ + /* Deprecated, unimplemented. */ + /* */ + typedef void + (*FT_Raster_BitSet_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_RASTER_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flag constants as used in the `flags' field of a */ + /* @FT_Raster_Params structure. */ + /* */ + /* <Values> */ + /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ + /* */ + /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ + /* anti-aliased glyph image should be */ + /* generated. Otherwise, it will be */ + /* monochrome (1-bit). */ + /* */ + /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ + /* rendering. In this mode, client */ + /* applications must provide their own span */ + /* callback. This lets them directly */ + /* draw or compose over an existing bitmap. */ + /* If this bit is not set, the target */ + /* pixmap's buffer _must_ be zeroed before */ + /* rendering. */ + /* */ + /* Direct rendering is only possible with */ + /* anti-aliased glyphs. */ + /* */ + /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ + /* rendering mode. If set, the output will */ + /* be clipped to a box specified in the */ + /* `clip_box' field of the */ + /* @FT_Raster_Params structure. */ + /* */ + /* Note that by default, the glyph bitmap */ + /* is clipped to the target pixmap, except */ + /* in direct rendering mode where all spans */ + /* are generated if no clipping box is set. */ + /* */ +#define FT_RASTER_FLAG_DEFAULT 0x0 +#define FT_RASTER_FLAG_AA 0x1 +#define FT_RASTER_FLAG_DIRECT 0x2 +#define FT_RASTER_FLAG_CLIP 0x4 + + /* these constants are deprecated; use the corresponding */ + /* `FT_RASTER_FLAG_XXX' values instead */ +#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT +#define ft_raster_flag_aa FT_RASTER_FLAG_AA +#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT +#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Raster_Params */ + /* */ + /* <Description> */ + /* A structure to hold the arguments used by a raster's render */ + /* function. */ + /* */ + /* <Fields> */ + /* target :: The target bitmap. */ + /* */ + /* source :: A pointer to the source glyph image (e.g., an */ + /* @FT_Outline). */ + /* */ + /* flags :: The rendering flags. */ + /* */ + /* gray_spans :: The gray span drawing callback. */ + /* */ + /* black_spans :: Unused. */ + /* */ + /* bit_test :: Unused. */ + /* */ + /* bit_set :: Unused. */ + /* */ + /* user :: User-supplied data that is passed to each drawing */ + /* callback. */ + /* */ + /* clip_box :: An optional clipping box. It is only used in */ + /* direct rendering mode. Note that coordinates here */ + /* should be expressed in _integer_ pixels (and not in */ + /* 26.6 fixed-point units). */ + /* */ + /* <Note> */ + /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ + /* bit flag is set in the `flags' field, otherwise a monochrome */ + /* bitmap is generated. */ + /* */ + /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ + /* raster will call the `gray_spans' callback to draw gray pixel */ + /* spans. This allows direct composition over a pre-existing bitmap */ + /* through user-provided callbacks to perform the span drawing and */ + /* composition. Not supported by the monochrome rasterizer. */ + /* */ + typedef struct FT_Raster_Params_ + { + const FT_Bitmap* target; + const void* source; + int flags; + FT_SpanFunc gray_spans; + FT_SpanFunc black_spans; /* unused */ + FT_Raster_BitTest_Func bit_test; /* unused */ + FT_Raster_BitSet_Func bit_set; /* unused */ + void* user; + FT_BBox clip_box; + + } FT_Raster_Params; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_NewFunc */ + /* */ + /* <Description> */ + /* A function used to create a new raster object. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory allocator. */ + /* */ + /* <Output> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `memory' parameter is a typeless pointer in order to avoid */ + /* un-wanted dependencies on the rest of the FreeType code. In */ + /* practice, it is an @FT_Memory object, i.e., a handle to the */ + /* standard FreeType memory allocator. However, this field can be */ + /* completely ignored by a given raster implementation. */ + /* */ + typedef int + (*FT_Raster_NewFunc)( void* memory, + FT_Raster* raster ); + +#define FT_Raster_New_Func FT_Raster_NewFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_DoneFunc */ + /* */ + /* <Description> */ + /* A function used to destroy a given raster object. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + typedef void + (*FT_Raster_DoneFunc)( FT_Raster raster ); + +#define FT_Raster_Done_Func FT_Raster_DoneFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_ResetFunc */ + /* */ + /* <Description> */ + /* FreeType used to provide an area of memory called the `render */ + /* pool' available to all registered rasters. This was not thread */ + /* safe however and now FreeType never allocates this pool. NULL */ + /* is always passed in as pool_base. */ + /* */ + /* This function is called each time the render pool changes, or just */ + /* after a new raster object is created. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* pool_base :: The address in memory of the render pool. */ + /* */ + /* pool_size :: The size in bytes of the render pool. */ + /* */ + /* <Note> */ + /* Rasters should ignore the render pool and rely on dynamic or stack */ + /* allocation if they want to (a handle to the memory allocator is */ + /* passed to the raster constructor). */ + /* */ + typedef void + (*FT_Raster_ResetFunc)( FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); + +#define FT_Raster_Reset_Func FT_Raster_ResetFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_SetModeFunc */ + /* */ + /* <Description> */ + /* This function is a generic facility to change modes or attributes */ + /* in a given raster. This can be used for debugging purposes, or */ + /* simply to allow implementation-specific `features' in a given */ + /* raster module. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* mode :: A 4-byte tag used to name the mode or property. */ + /* */ + /* args :: A pointer to the new mode/property to use. */ + /* */ + typedef int + (*FT_Raster_SetModeFunc)( FT_Raster raster, + unsigned long mode, + void* args ); + +#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_RenderFunc */ + /* */ + /* <Description> */ + /* Invoke a given raster to scan-convert a given glyph image into a */ + /* target bitmap. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ + /* store the rendering parameters. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + /* <Note> */ + /* The exact format of the source image depends on the raster's glyph */ + /* format defined in its @FT_Raster_Funcs structure. It can be an */ + /* @FT_Outline or anything else in order to support a large array of */ + /* glyph formats. */ + /* */ + /* Note also that the render function can fail and return a */ + /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ + /* not support direct composition. */ + /* */ + /* XXX: For now, the standard raster doesn't support direct */ + /* composition but this should change for the final release (see */ + /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ + /* for examples of distinct implementations that support direct */ + /* composition). */ + /* */ + typedef int + (*FT_Raster_RenderFunc)( FT_Raster raster, + const FT_Raster_Params* params ); + +#define FT_Raster_Render_Func FT_Raster_RenderFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Raster_Funcs */ + /* */ + /* <Description> */ + /* A structure used to describe a given raster class to the library. */ + /* */ + /* <Fields> */ + /* glyph_format :: The supported glyph format for this raster. */ + /* */ + /* raster_new :: The raster constructor. */ + /* */ + /* raster_reset :: Used to reset the render pool within the raster. */ + /* */ + /* raster_render :: A function to render a glyph into a given bitmap. */ + /* */ + /* raster_done :: The raster destructor. */ + /* */ + typedef struct FT_Raster_Funcs_ + { + FT_Glyph_Format glyph_format; + FT_Raster_NewFunc raster_new; + FT_Raster_ResetFunc raster_reset; + FT_Raster_SetModeFunc raster_set_mode; + FT_Raster_RenderFunc raster_render; + FT_Raster_DoneFunc raster_done; + + } FT_Raster_Funcs; + + /* */ + + +FT_END_HEADER + +#endif /* FTIMAGE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/ftincrem.h b/foreign/freetype2/freetype/ftincrem.h new file mode 100644 index 0000000..46b58b7 --- /dev/null +++ b/foreign/freetype2/freetype/ftincrem.h @@ -0,0 +1,354 @@ +/***************************************************************************/ +/* */ +/* ftincrem.h */ +/* */ +/* FreeType incremental loading (specification). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTINCREM_H_ +#define FTINCREM_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************** + * + * @section: + * incremental + * + * @title: + * Incremental Loading + * + * @abstract: + * Custom Glyph Loading. + * + * @description: + * This section contains various functions used to perform so-called + * `incremental' glyph loading. This is a mode where all glyphs loaded + * from a given @FT_Face are provided by the client application. + * + * Apart from that, all other tables are loaded normally from the font + * file. This mode is useful when FreeType is used within another + * engine, e.g., a PostScript Imaging Processor. + * + * To enable this mode, you must use @FT_Open_Face, passing an + * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an + * @FT_Incremental_Interface value. See the comments for + * @FT_Incremental_InterfaceRec for an example. + * + */ + + + /*************************************************************************** + * + * @type: + * FT_Incremental + * + * @description: + * An opaque type describing a user-provided object used to implement + * `incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., PostScript interpreters), + * where the glyph data isn't in the font file, or must be overridden by + * different values. + * + * @note: + * It is up to client applications to create and implement @FT_Incremental + * objects, as long as they provide implementations for the methods + * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc + * and @FT_Incremental_GetGlyphMetricsFunc. + * + * See the description of @FT_Incremental_InterfaceRec to understand how + * to use incremental objects with FreeType. + * + */ + typedef struct FT_IncrementalRec_* FT_Incremental; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_MetricsRec + * + * @description: + * A small structure used to contain the basic glyph metrics returned + * by the @FT_Incremental_GetGlyphMetricsFunc method. + * + * @fields: + * bearing_x :: + * Left bearing, in font units. + * + * bearing_y :: + * Top bearing, in font units. + * + * advance :: + * Horizontal component of glyph advance, in font units. + * + * advance_v :: + * Vertical component of glyph advance, in font units. + * + * @note: + * These correspond to horizontal or vertical metrics depending on the + * value of the `vertical' argument to the function + * @FT_Incremental_GetGlyphMetricsFunc. + * + */ + typedef struct FT_Incremental_MetricsRec_ + { + FT_Long bearing_x; + FT_Long bearing_y; + FT_Long advance; + FT_Long advance_v; /* since 2.3.12 */ + + } FT_Incremental_MetricsRec; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_Metrics + * + * @description: + * A handle to an @FT_Incremental_MetricsRec structure. + * + */ + typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; + + + /*************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphDataFunc + * + * @description: + * A function called by FreeType to access a given glyph's data bytes + * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is + * enabled. + * + * Note that the format of the glyph's data bytes depends on the font + * file format. For TrueType, it must correspond to the raw bytes within + * the `glyf' table. For PostScript formats, it must correspond to the + * *unencrypted* charstring bytes, without any `lenIV' header. It is + * undefined for any other format. + * + * @input: + * incremental :: + * Handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * @output: + * adata :: + * A structure describing the returned glyph data bytes (which will be + * accessed as a read-only byte block). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function returns successfully the method + * @FT_Incremental_FreeGlyphDataFunc will be called later to release + * the data bytes. + * + * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for + * compound glyphs. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Data* adata ); + + + /*************************************************************************** + * + * @type: + * FT_Incremental_FreeGlyphDataFunc + * + * @description: + * A function used to release the glyph data bytes returned by a + * successful call to @FT_Incremental_GetGlyphDataFunc. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * data :: + * A structure describing the glyph data bytes (which will be accessed + * as a read-only byte block). + * + */ + typedef void + (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, + FT_Data* data ); + + + /*************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphMetricsFunc + * + * @description: + * A function used to retrieve the basic metrics of a given glyph index + * before accessing its data. This is necessary because, in certain + * formats like TrueType, the metrics are stored in a different place from + * the glyph images proper. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * vertical :: + * If true, return vertical metrics. + * + * ametrics :: + * This parameter is used for both input and output. + * The original glyph metrics, if any, in font units. If metrics are + * not available all the values must be set to zero. + * + * @output: + * ametrics :: + * The replacement glyph metrics in font units. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphMetricsFunc) + ( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Bool vertical, + FT_Incremental_MetricsRec *ametrics ); + + + /************************************************************************** + * + * @struct: + * FT_Incremental_FuncsRec + * + * @description: + * A table of functions for accessing fonts that load data + * incrementally. Used in @FT_Incremental_InterfaceRec. + * + * @fields: + * get_glyph_data :: + * The function to get glyph data. Must not be null. + * + * free_glyph_data :: + * The function to release glyph data. Must not be null. + * + * get_glyph_metrics :: + * The function to get glyph metrics. May be null if the font does + * not provide overriding glyph metrics. + * + */ + typedef struct FT_Incremental_FuncsRec_ + { + FT_Incremental_GetGlyphDataFunc get_glyph_data; + FT_Incremental_FreeGlyphDataFunc free_glyph_data; + FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics; + + } FT_Incremental_FuncsRec; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_InterfaceRec + * + * @description: + * A structure to be used with @FT_Open_Face to indicate that the user + * wants to support incremental glyph loading. You should use it with + * @FT_PARAM_TAG_INCREMENTAL as in the following example: + * + * { + * FT_Incremental_InterfaceRec inc_int; + * FT_Parameter parameter; + * FT_Open_Args open_args; + * + * + * // set up incremental descriptor + * inc_int.funcs = my_funcs; + * inc_int.object = my_object; + * + * // set up optional parameter + * parameter.tag = FT_PARAM_TAG_INCREMENTAL; + * parameter.data = &inc_int; + * + * // set up FT_Open_Args structure + * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; + * open_args.pathname = my_font_pathname; + * open_args.num_params = 1; + * open_args.params = ¶meter; // we use one optional argument + * + * // open the font + * error = FT_Open_Face( library, &open_args, index, &face ); + * ... + * } + * + */ + typedef struct FT_Incremental_InterfaceRec_ + { + const FT_Incremental_FuncsRec* funcs; + FT_Incremental object; + + } FT_Incremental_InterfaceRec; + + + /*************************************************************************** + * + * @type: + * FT_Incremental_Interface + * + * @description: + * A pointer to an @FT_Incremental_InterfaceRec structure. + * + */ + typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_INCREMENTAL + * + * @description: + * A constant used as the tag of @FT_Parameter structures to indicate + * an incremental loading object to be used by FreeType. + * + */ +#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) + + /* */ + + +FT_END_HEADER + +#endif /* FTINCREM_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftlcdfil.h b/foreign/freetype2/freetype/ftlcdfil.h new file mode 100644 index 0000000..e06a895 --- /dev/null +++ b/foreign/freetype2/freetype/ftlcdfil.h @@ -0,0 +1,286 @@ +/***************************************************************************/ +/* */ +/* ftlcdfil.h */ +/* */ +/* FreeType API for color filtering of subpixel bitmap glyphs */ +/* (specification). */ +/* */ +/* Copyright 2006-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTLCDFIL_H_ +#define FTLCDFIL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************** + * + * @section: + * lcd_filtering + * + * @title: + * LCD Filtering + * + * @abstract: + * Reduce color fringes of subpixel-rendered bitmaps. + * + * @description: + * Subpixel rendering exploits the color-striped structure of LCD + * pixels, increasing the available resolution in the direction of the + * stripe (usually horizontal RGB) by a factor of~3. Since these + * subpixels are color pixels, using them unfiltered creates severe + * color fringes. Use the @FT_Library_SetLcdFilter API to specify a + * low-pass filter, which is then applied to subpixel-rendered bitmaps + * generated through @FT_Render_Glyph. The filter sacrifices some of + * the higher resolution to reduce color fringes, making the glyph image + * slightly blurrier. Positional improvements will remain. + * + * Note that no filter is active by default, and that this function is + * *not* implemented in default builds of the library. You need to + * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file + * in order to activate it and explicitly call @FT_Library_SetLcdFilter + * to enable it. + * + * A filter should have two properties: + * + * 1) It should be normalized, meaning the sum of the 5~components + * should be 256 (0x100). It is possible to go above or under this + * target sum, however: going under means tossing out contrast, going + * over means invoking clamping and thereby non-linearities that + * increase contrast somewhat at the expense of greater distortion + * and color-fringing. Contrast is better enhanced through stem + * darkening. + * + * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' + * where a~+ b~=~c. It distributes the computed coverage for one + * subpixel to all subpixels equally, sacrificing some won resolution + * but drastically reducing color-fringing. Positioning improvements + * remain! Note that color-fringing can only really be minimized + * when using a color-balanced filter and alpha-blending the glyph + * onto a surface in linear space; see @FT_Render_Glyph. + * + * Regarding the form, a filter can be a `boxy' filter or a `beveled' + * filter. Boxy filters are sharper but are less forgiving of non-ideal + * gamma curves of a screen (viewing angles!), beveled filters are + * fuzzier but more tolerant. + * + * Examples: + * + * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor + * normalized. + * + * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not + * normalized. + * + * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not + * balanced. + * + * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not + * balanced. + * + * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost + * balanced. + * + * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost + * balanced. + * + * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, + * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output + * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. + * + * If this feature is activated, the dimensions of LCD glyph bitmaps are + * either wider or taller than the dimensions of the corresponding + * outline with regard to the pixel grid. For example, for + * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and + * 3~subpixels to the right. The bitmap offset values are adjusted + * accordingly, so clients shouldn't need to modify their layout and + * glyph positioning code when enabling the filter. + * + * It is important to understand that linear alpha blending and gamma + * correction is critical for correctly rendering glyphs onto surfaces + * without artifacts and even more critical when subpixel rendering is + * involved. + * + * Each of the 3~alpha values (subpixels) is independently used to blend + * one color channel. That is, red alpha blends the red channel of the + * text color with the red channel of the background pixel. The + * distribution of density values by the color-balanced filter assumes + * alpha blending is done in linear space; only then color artifacts + * cancel out. + */ + + + /**************************************************************************** + * + * @enum: + * FT_LcdFilter + * + * @description: + * A list of values to identify various types of LCD filters. + * + * @values: + * FT_LCD_FILTER_NONE :: + * Do not perform filtering. When used with subpixel rendering, this + * results in sometimes severe color fringes. + * + * FT_LCD_FILTER_DEFAULT :: + * The default filter reduces color fringes considerably, at the cost + * of a slight blurriness in the output. + * + * It is a beveled, normalized, and color-balanced five-tap filter + * that is more forgiving to screens with non-ideal gamma curves and + * viewing angles. Note that while color-fringing is reduced, it can + * only be minimized by using linear alpha blending and gamma + * correction to render glyphs onto surfaces. The default filter + * weights are [0x08 0x4D 0x56 0x4D 0x08]. + * + * FT_LCD_FILTER_LIGHT :: + * The light filter is a variant that is sharper at the cost of + * slightly more color fringes than the default one. + * + * It is a boxy, normalized, and color-balanced three-tap filter that + * is less forgiving to screens with non-ideal gamma curves and + * viewing angles. This filter works best when the rendering system + * uses linear alpha blending and gamma correction to render glyphs + * onto surfaces. The light filter weights are + * [0x00 0x55 0x56 0x55 0x00]. + * + * FT_LCD_FILTER_LEGACY :: + * This filter corresponds to the original libXft color filter. It + * provides high contrast output but can exhibit really bad color + * fringes if glyphs are not extremely well hinted to the pixel grid. + * In other words, it only works well if the TrueType bytecode + * interpreter is enabled *and* high-quality hinted fonts are used. + * + * This filter is only provided for comparison purposes, and might be + * disabled or stay unsupported in the future. + * + * FT_LCD_FILTER_LEGACY1 :: + * For historical reasons, the FontConfig library returns a different + * enumeration value for legacy LCD filtering. To make code work that + * (incorrectly) forwards FontConfig's enumeration value to + * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest + * to have another enumeration value, which is completely equal to + * `FT_LCD_FILTER_LEGACY'. + * + * @since: + * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) + */ + typedef enum FT_LcdFilter_ + { + FT_LCD_FILTER_NONE = 0, + FT_LCD_FILTER_DEFAULT = 1, + FT_LCD_FILTER_LIGHT = 2, + FT_LCD_FILTER_LEGACY1 = 3, + FT_LCD_FILTER_LEGACY = 16, + + FT_LCD_FILTER_MAX /* do not remove */ + + } FT_LcdFilter; + + + /************************************************************************** + * + * @func: + * FT_Library_SetLcdFilter + * + * @description: + * This function is used to apply color filtering to LCD decimated + * bitmaps, like the ones used when calling @FT_Render_Glyph with + * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. + * + * @input: + * library :: + * A handle to the target library instance. + * + * filter :: + * The filter type. + * + * You can use @FT_LCD_FILTER_NONE here to disable this feature, or + * @FT_LCD_FILTER_DEFAULT to use a default filter that should work + * well on most LCD screens. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This feature is always disabled by default. Clients must make an + * explicit call to this function with a `filter' value other than + * @FT_LCD_FILTER_NONE in order to enable it. + * + * Due to *PATENTS* covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature' if the + * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * defined in your build of the library, which should correspond to all + * default builds of FreeType. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilter( FT_Library library, + FT_LcdFilter filter ); + + + /************************************************************************** + * + * @func: + * FT_Library_SetLcdFilterWeights + * + * @description: + * This function can be used to enable LCD filter with custom weights, + * instead of using presets in @FT_Library_SetLcdFilter. + * + * @input: + * library :: + * A handle to the target library instance. + * + * weights :: + * A pointer to an array; the function copies the first five bytes and + * uses them to specify the filter weights. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Due to *PATENTS* covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature' if the + * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * defined in your build of the library, which should correspond to all + * default builds of FreeType. + * + * @since: + * 2.4.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilterWeights( FT_Library library, + unsigned char *weights ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLCDFIL_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftlist.h b/foreign/freetype2/freetype/ftlist.h new file mode 100644 index 0000000..82f437a --- /dev/null +++ b/foreign/freetype2/freetype/ftlist.h @@ -0,0 +1,276 @@ +/***************************************************************************/ +/* */ +/* ftlist.h */ +/* */ +/* Generic list support for FreeType (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file implements functions relative to list processing. Its */ + /* data structures are defined in `freetype.h'. */ + /* */ + /*************************************************************************/ + + +#ifndef FTLIST_H_ +#define FTLIST_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* list_processing */ + /* */ + /* <Title> */ + /* List Processing */ + /* */ + /* <Abstract> */ + /* Simple management of lists. */ + /* */ + /* <Description> */ + /* This section contains various definitions related to list */ + /* processing using doubly-linked nodes. */ + /* */ + /* <Order> */ + /* FT_List */ + /* FT_ListNode */ + /* FT_ListRec */ + /* FT_ListNodeRec */ + /* */ + /* FT_List_Add */ + /* FT_List_Insert */ + /* FT_List_Find */ + /* FT_List_Remove */ + /* FT_List_Up */ + /* FT_List_Iterate */ + /* FT_List_Iterator */ + /* FT_List_Finalize */ + /* FT_List_Destructor */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Find */ + /* */ + /* <Description> */ + /* Find the list node for a given listed object. */ + /* */ + /* <Input> */ + /* list :: A pointer to the parent list. */ + /* data :: The address of the listed object. */ + /* */ + /* <Return> */ + /* List node. NULL if it wasn't found. */ + /* */ + FT_EXPORT( FT_ListNode ) + FT_List_Find( FT_List list, + void* data ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Add */ + /* */ + /* <Description> */ + /* Append an element to the end of a list. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* node :: The node to append. */ + /* */ + FT_EXPORT( void ) + FT_List_Add( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Insert */ + /* */ + /* <Description> */ + /* Insert an element at the head of a list. */ + /* */ + /* <InOut> */ + /* list :: A pointer to parent list. */ + /* node :: The node to insert. */ + /* */ + FT_EXPORT( void ) + FT_List_Insert( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Remove */ + /* */ + /* <Description> */ + /* Remove a node from a list. This function doesn't check whether */ + /* the node is in the list! */ + /* */ + /* <Input> */ + /* node :: The node to remove. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* */ + FT_EXPORT( void ) + FT_List_Remove( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Up */ + /* */ + /* <Description> */ + /* Move a node to the head/top of a list. Used to maintain LRU */ + /* lists. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* node :: The node to move. */ + /* */ + FT_EXPORT( void ) + FT_List_Up( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_List_Iterator */ + /* */ + /* <Description> */ + /* An FT_List iterator function that is called during a list parse */ + /* by @FT_List_Iterate. */ + /* */ + /* <Input> */ + /* node :: The current iteration list node. */ + /* */ + /* user :: A typeless pointer passed to @FT_List_Iterate. */ + /* Can be used to point to the iteration's state. */ + /* */ + typedef FT_Error + (*FT_List_Iterator)( FT_ListNode node, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Iterate */ + /* */ + /* <Description> */ + /* Parse a list and calls a given iterator function on each element. */ + /* Note that parsing is stopped as soon as one of the iterator calls */ + /* returns a non-zero value. */ + /* */ + /* <Input> */ + /* list :: A handle to the list. */ + /* iterator :: An iterator function, called on each node of the list. */ + /* user :: A user-supplied field that is passed as the second */ + /* argument to the iterator. */ + /* */ + /* <Return> */ + /* The result (a FreeType error code) of the last iterator call. */ + /* */ + FT_EXPORT( FT_Error ) + FT_List_Iterate( FT_List list, + FT_List_Iterator iterator, + void* user ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_List_Destructor */ + /* */ + /* <Description> */ + /* An @FT_List iterator function that is called during a list */ + /* finalization by @FT_List_Finalize to destroy all elements in a */ + /* given list. */ + /* */ + /* <Input> */ + /* system :: The current system object. */ + /* */ + /* data :: The current object to destroy. */ + /* */ + /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ + /* be used to point to the iteration's state. */ + /* */ + typedef void + (*FT_List_Destructor)( FT_Memory memory, + void* data, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Finalize */ + /* */ + /* <Description> */ + /* Destroy all elements in the list as well as the list itself. */ + /* */ + /* <Input> */ + /* list :: A handle to the list. */ + /* */ + /* destroy :: A list destructor that will be applied to each element */ + /* of the list. Set this to NULL if not needed. */ + /* */ + /* memory :: The current memory object that handles deallocation. */ + /* */ + /* user :: A user-supplied field that is passed as the last */ + /* argument to the destructor. */ + /* */ + /* <Note> */ + /* This function expects that all nodes added by @FT_List_Add or */ + /* @FT_List_Insert have been dynamically allocated. */ + /* */ + FT_EXPORT( void ) + FT_List_Finalize( FT_List list, + FT_List_Destructor destroy, + FT_Memory memory, + void* user ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLIST_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftlzw.h b/foreign/freetype2/freetype/ftlzw.h new file mode 100644 index 0000000..582e2c1 --- /dev/null +++ b/foreign/freetype2/freetype/ftlzw.h @@ -0,0 +1,99 @@ +/***************************************************************************/ +/* */ +/* ftlzw.h */ +/* */ +/* LZW-compressed stream support. */ +/* */ +/* Copyright 2004-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTLZW_H_ +#define FTLZW_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* lzw */ + /* */ + /* <Title> */ + /* LZW Streams */ + /* */ + /* <Abstract> */ + /* Using LZW-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of LZW-specific functions. */ + /* */ + /*************************************************************************/ + + /************************************************************************ + * + * @function: + * FT_Stream_OpenLZW + * + * @description: + * Open a new stream to parse LZW-compressed font files. This is + * mainly used to support the compressed `*.pcf.Z' fonts that come + * with XFree86. + * + * @input: + * stream :: The target embedding stream. + * + * source :: The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream + * + * In certain builds of the library, LZW compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a LZW stream from it + * and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with LZW support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenLZW( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLZW_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftmac.h b/foreign/freetype2/freetype/ftmac.h new file mode 100644 index 0000000..adb15ca --- /dev/null +++ b/foreign/freetype2/freetype/ftmac.h @@ -0,0 +1,274 @@ +/***************************************************************************/ +/* */ +/* ftmac.h */ +/* */ +/* Additional Mac-specific API. */ +/* */ +/* Copyright 1996-2016 by */ +/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* NOTE: Include this file after FT_FREETYPE_H and after any */ +/* Mac-specific headers (because this header uses Mac types such as */ +/* Handle, FSSpec, FSRef, etc.) */ +/* */ +/***************************************************************************/ + + +#ifndef FTMAC_H_ +#define FTMAC_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + +/* gcc-3.4.1 and later can warn about functions tagged as deprecated */ +#ifndef FT_DEPRECATED_ATTRIBUTE +#if defined(__GNUC__) && \ + ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#define FT_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) +#else +#define FT_DEPRECATED_ATTRIBUTE +#endif +#endif + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* mac_specific */ + /* */ + /* <Title> */ + /* Mac Specific Interface */ + /* */ + /* <Abstract> */ + /* Only available on the Macintosh. */ + /* */ + /* <Description> */ + /* The following definitions are only available if FreeType is */ + /* compiled on a Macintosh. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FOND */ + /* */ + /* <Description> */ + /* Create a new face object from a FOND resource. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* fond :: A FOND resource. */ + /* */ + /* face_index :: Only supported for the -1 `sanity check' special */ + /* case. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Notes> */ + /* This function can be used to create @FT_Face objects from fonts */ + /* that are installed in the system as follows. */ + /* */ + /* { */ + /* fond = GetResource( 'FOND', fontName ); */ + /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FOND( FT_Library library, + Handle fond, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFile_From_Mac_Name */ + /* */ + /* <Description> */ + /* Return an FSSpec for the disk file containing the named font. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font (e.g., Times New Roman */ + /* Bold). */ + /* */ + /* <Output> */ + /* pathSpec :: FSSpec to the file. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* face_index :: Index of the face. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFile_From_Mac_ATS_Name */ + /* */ + /* <Description> */ + /* Return an FSSpec for the disk file containing the named font. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font in ATS framework. */ + /* */ + /* <Output> */ + /* pathSpec :: FSSpec to the file. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* face_index :: Index of the face. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFilePath_From_Mac_ATS_Name */ + /* */ + /* <Description> */ + /* Return a pathname of the disk file and face index for given font */ + /* name that is handled by ATS framework. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font in ATS framework. */ + /* */ + /* <Output> */ + /* path :: Buffer to store pathname of the file. For passing */ + /* to @FT_New_Face. The client must allocate this */ + /* buffer before calling this function. */ + /* */ + /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ + /* */ + /* face_index :: Index of the face. For passing to @FT_New_Face. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, + UInt8* path, + UInt32 maxPathSize, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSSpec */ + /* */ + /* <Description> */ + /* Create a new face object from a given resource and typeface index */ + /* using an FSSpec to the font file. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* spec :: FSSpec to the font file. */ + /* */ + /* face_index :: The index of the face within the resource. The */ + /* first face has index~0. */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ + /* it accepts an FSSpec instead of a path. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSSpec( FT_Library library, + const FSSpec *spec, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSRef */ + /* */ + /* <Description> */ + /* Create a new face object from a given resource and typeface index */ + /* using an FSRef to the font file. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* spec :: FSRef to the font file. */ + /* */ + /* face_index :: The index of the face within the resource. The */ + /* first face has index~0. */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ + /* it accepts an FSRef instead of a path. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSRef( FT_Library library, + const FSRef *ref, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + /* */ + + +FT_END_HEADER + + +#endif /* FTMAC_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftmm.h b/foreign/freetype2/freetype/ftmm.h new file mode 100644 index 0000000..6c05f0c --- /dev/null +++ b/foreign/freetype2/freetype/ftmm.h @@ -0,0 +1,384 @@ +/***************************************************************************/ +/* */ +/* ftmm.h */ +/* */ +/* FreeType Multiple Master font interface (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTMM_H_ +#define FTMM_H_ + + +#include <ft2build.h> +#include FT_TYPE1_TABLES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* multiple_masters */ + /* */ + /* <Title> */ + /* Multiple Masters */ + /* */ + /* <Abstract> */ + /* How to manage Multiple Masters fonts. */ + /* */ + /* <Description> */ + /* The following types and functions are used to manage Multiple */ + /* Master fonts, i.e., the selection of specific design instances by */ + /* setting design axis coordinates. */ + /* */ + /* George Williams has extended this interface to make it work with */ + /* both Type~1 Multiple Masters fonts and GX distortable (var) */ + /* fonts. Some of these routines only work with MM fonts, others */ + /* will work with both types. They are similar enough that a */ + /* consistent interface makes sense. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_MM_Axis */ + /* */ + /* <Description> */ + /* A simple structure used to model a given axis in design space for */ + /* Multiple Masters fonts. */ + /* */ + /* This structure can't be used for GX var fonts. */ + /* */ + /* <Fields> */ + /* name :: The axis's name. */ + /* */ + /* minimum :: The axis's minimum design coordinate. */ + /* */ + /* maximum :: The axis's maximum design coordinate. */ + /* */ + typedef struct FT_MM_Axis_ + { + FT_String* name; + FT_Long minimum; + FT_Long maximum; + + } FT_MM_Axis; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Multi_Master */ + /* */ + /* <Description> */ + /* A structure used to model the axes and space of a Multiple Masters */ + /* font. */ + /* */ + /* This structure can't be used for GX var fonts. */ + /* */ + /* <Fields> */ + /* num_axis :: Number of axes. Cannot exceed~4. */ + /* */ + /* num_designs :: Number of designs; should be normally 2^num_axis */ + /* even though the Type~1 specification strangely */ + /* allows for intermediate designs to be present. */ + /* This number cannot exceed~16. */ + /* */ + /* axis :: A table of axis descriptors. */ + /* */ + typedef struct FT_Multi_Master_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_MM_Axis axis[T1_MAX_MM_AXIS]; + + } FT_Multi_Master; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Var_Axis */ + /* */ + /* <Description> */ + /* A simple structure used to model a given axis in design space for */ + /* Multiple Masters and GX var fonts. */ + /* */ + /* <Fields> */ + /* name :: The axis's name. */ + /* Not always meaningful for GX. */ + /* */ + /* minimum :: The axis's minimum design coordinate. */ + /* */ + /* def :: The axis's default design coordinate. */ + /* FreeType computes meaningful default values for MM; it */ + /* is then an integer value, not in 16.16 format. */ + /* */ + /* maximum :: The axis's maximum design coordinate. */ + /* */ + /* tag :: The axis's tag (the GX equivalent to `name'). */ + /* FreeType provides default values for MM if possible. */ + /* */ + /* strid :: The entry in `name' table (another GX version of */ + /* `name'). */ + /* Not meaningful for MM. */ + /* */ + typedef struct FT_Var_Axis_ + { + FT_String* name; + + FT_Fixed minimum; + FT_Fixed def; + FT_Fixed maximum; + + FT_ULong tag; + FT_UInt strid; + + } FT_Var_Axis; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Var_Named_Style */ + /* */ + /* <Description> */ + /* A simple structure used to model a named style in a GX var font. */ + /* */ + /* This structure can't be used for MM fonts. */ + /* */ + /* <Fields> */ + /* coords :: The design coordinates for this style. */ + /* This is an array with one entry for each axis. */ + /* */ + /* strid :: The entry in `name' table identifying this style. */ + /* */ + typedef struct FT_Var_Named_Style_ + { + FT_Fixed* coords; + FT_UInt strid; + + } FT_Var_Named_Style; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_MM_Var */ + /* */ + /* <Description> */ + /* A structure used to model the axes and space of a Multiple Masters */ + /* or GX var distortable font. */ + /* */ + /* Some fields are specific to one format and not to the other. */ + /* */ + /* <Fields> */ + /* num_axis :: The number of axes. The maximum value is~4 for */ + /* MM; no limit in GX. */ + /* */ + /* num_designs :: The number of designs; should be normally */ + /* 2^num_axis for MM fonts. Not meaningful for GX */ + /* (where every glyph could have a different */ + /* number of designs). */ + /* */ + /* num_namedstyles :: The number of named styles; only meaningful for */ + /* GX that allows certain design coordinates to */ + /* have a string ID (in the `name' table) */ + /* associated with them. The font can tell the */ + /* user that, for example, Weight=1.5 is `Bold'. */ + /* */ + /* axis :: An axis descriptor table. */ + /* GX fonts contain slightly more data than MM. */ + /* Memory management of this pointer is done */ + /* internally by FreeType. */ + /* */ + /* namedstyle :: A named style table. */ + /* Only meaningful with GX. */ + /* Memory management of this pointer is done */ + /* internally by FreeType. */ + /* */ + typedef struct FT_MM_Var_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_UInt num_namedstyles; + FT_Var_Axis* axis; + FT_Var_Named_Style* namedstyle; + + } FT_MM_Var; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Multi_Master */ + /* */ + /* <Description> */ + /* Retrieve the Multiple Master descriptor of a given font. */ + /* */ + /* This function can't be used with GX fonts. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Output> */ + /* amaster :: The Multiple Masters descriptor. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Multi_Master( FT_Face face, + FT_Multi_Master *amaster ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_MM_Var */ + /* */ + /* <Description> */ + /* Retrieve the Multiple Master/GX var descriptor of a given font. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Output> */ + /* amaster :: The Multiple Masters/GX var descriptor. */ + /* Allocates a data structure, which the user must */ + /* deallocate with `free' after use. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Var( FT_Face face, + FT_MM_Var* *amaster ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_MM_Design_Coordinates */ + /* */ + /* <Description> */ + /* For Multiple Masters fonts, choose an interpolated font design */ + /* through design coordinates. */ + /* */ + /* This function can't be used with GX fonts. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: An array of design coordinates. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Var_Design_Coordinates */ + /* */ + /* <Description> */ + /* For Multiple Master or GX Var fonts, choose an interpolated font */ + /* design through design coordinates. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: An array of design coordinates. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_MM_Blend_Coordinates */ + /* */ + /* <Description> */ + /* For Multiple Masters and GX var fonts, choose an interpolated font */ + /* design through normalized blend coordinates. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: The design coordinates array (each element must be */ + /* between 0 and 1.0). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Var_Blend_Coordinates */ + /* */ + /* <Description> */ + /* This is another name of @FT_Set_MM_Blend_Coordinates. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMM_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftmodapi.h b/foreign/freetype2/freetype/ftmodapi.h new file mode 100644 index 0000000..b4d2758 --- /dev/null +++ b/foreign/freetype2/freetype/ftmodapi.h @@ -0,0 +1,667 @@ +/***************************************************************************/ +/* */ +/* ftmodapi.h */ +/* */ +/* FreeType modules public interface (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTMODAPI_H_ +#define FTMODAPI_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /* <Title> */ + /* Module Management */ + /* */ + /* <Abstract> */ + /* How to add, upgrade, remove, and control modules from FreeType. */ + /* */ + /* <Description> */ + /* The definitions below are used to manage modules within FreeType. */ + /* Modules can be added, upgraded, and removed at runtime. */ + /* Additionally, some module properties can be controlled also. */ + /* */ + /* Here is a list of possible values of the `module_name' field in */ + /* the @FT_Module_Class structure. */ + /* */ + /* { */ + /* autofitter */ + /* bdf */ + /* cff */ + /* gxvalid */ + /* otvalid */ + /* pcf */ + /* pfr */ + /* psaux */ + /* pshinter */ + /* psnames */ + /* raster1 */ + /* sfnt */ + /* smooth, smooth-lcd, smooth-lcdv */ + /* truetype */ + /* type1 */ + /* type42 */ + /* t1cid */ + /* winfonts */ + /* } */ + /* */ + /* Note that the FreeType Cache sub-system is not a FreeType module. */ + /* */ + /* <Order> */ + /* FT_Module */ + /* FT_Module_Constructor */ + /* FT_Module_Destructor */ + /* FT_Module_Requester */ + /* FT_Module_Class */ + /* */ + /* FT_Add_Module */ + /* FT_Get_Module */ + /* FT_Remove_Module */ + /* FT_Add_Default_Modules */ + /* */ + /* FT_Property_Set */ + /* FT_Property_Get */ + /* */ + /* FT_New_Library */ + /* FT_Done_Library */ + /* FT_Reference_Library */ + /* */ + /* FT_Renderer */ + /* FT_Renderer_Class */ + /* */ + /* FT_Get_Renderer */ + /* FT_Set_Renderer */ + /* */ + /* FT_Set_Debug_Hook */ + /* */ + /*************************************************************************/ + + + /* module bit flags */ +#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */ +#define FT_MODULE_RENDERER 2 /* this module is a renderer */ +#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */ +#define FT_MODULE_STYLER 8 /* this module is a styler */ + +#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */ + /* scalable fonts */ +#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */ + /* support vector outlines */ +#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */ + /* own hinter */ +#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */ + /* produces LIGHT hints */ + + + /* deprecated values */ +#define ft_module_font_driver FT_MODULE_FONT_DRIVER +#define ft_module_renderer FT_MODULE_RENDERER +#define ft_module_hinter FT_MODULE_HINTER +#define ft_module_styler FT_MODULE_STYLER + +#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE +#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES +#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER +#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY + + + typedef FT_Pointer FT_Module_Interface; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Constructor */ + /* */ + /* <Description> */ + /* A function used to initialize (not create) a new module object. */ + /* */ + /* <Input> */ + /* module :: The module to initialize. */ + /* */ + typedef FT_Error + (*FT_Module_Constructor)( FT_Module module ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Destructor */ + /* */ + /* <Description> */ + /* A function used to finalize (not destroy) a given module object. */ + /* */ + /* <Input> */ + /* module :: The module to finalize. */ + /* */ + typedef void + (*FT_Module_Destructor)( FT_Module module ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Requester */ + /* */ + /* <Description> */ + /* A function used to query a given module for a specific interface. */ + /* */ + /* <Input> */ + /* module :: The module to be searched. */ + /* */ + /* name :: The name of the interface in the module. */ + /* */ + typedef FT_Module_Interface + (*FT_Module_Requester)( FT_Module module, + const char* name ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Module_Class */ + /* */ + /* <Description> */ + /* The module class descriptor. */ + /* */ + /* <Fields> */ + /* module_flags :: Bit flags describing the module. */ + /* */ + /* module_size :: The size of one module object/instance in */ + /* bytes. */ + /* */ + /* module_name :: The name of the module. */ + /* */ + /* module_version :: The version, as a 16.16 fixed number */ + /* (major.minor). */ + /* */ + /* module_requires :: The version of FreeType this module requires, */ + /* as a 16.16 fixed number (major.minor). Starts */ + /* at version 2.0, i.e., 0x20000. */ + /* */ + /* module_init :: The initializing function. */ + /* */ + /* module_done :: The finalizing function. */ + /* */ + /* get_interface :: The interface requesting function. */ + /* */ + typedef struct FT_Module_Class_ + { + FT_ULong module_flags; + FT_Long module_size; + const FT_String* module_name; + FT_Fixed module_version; + FT_Fixed module_requires; + + const void* module_interface; + + FT_Module_Constructor module_init; + FT_Module_Destructor module_done; + FT_Module_Requester get_interface; + + } FT_Module_Class; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Add_Module */ + /* */ + /* <Description> */ + /* Add a new module to a given library instance. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* clazz :: A pointer to class descriptor for the module. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* An error will be returned if a module already exists by that name, */ + /* or if the module requires a version of FreeType that is too great. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Add_Module( FT_Library library, + const FT_Module_Class* clazz ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Module */ + /* */ + /* <Description> */ + /* Find a module by its name. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object. */ + /* */ + /* module_name :: The module's name (as an ASCII string). */ + /* */ + /* <Return> */ + /* A module handle. 0~if none was found. */ + /* */ + /* <Note> */ + /* FreeType's internal modules aren't documented very well, and you */ + /* should look up the source code for details. */ + /* */ + FT_EXPORT( FT_Module ) + FT_Get_Module( FT_Library library, + const char* module_name ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Remove_Module */ + /* */ + /* <Description> */ + /* Remove a given module from a library instance. */ + /* */ + /* <InOut> */ + /* library :: A handle to a library object. */ + /* */ + /* <Input> */ + /* module :: A handle to a module object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The module object is destroyed by the function in case of success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Remove_Module( FT_Library library, + FT_Module module ); + + + /********************************************************************** + * + * @function: + * FT_Property_Set + * + * @description: + * Set a property for a given module. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in the `Synopsis' + * subsection of the module's documentation. + * + * Note that only a few modules have properties. + * + * value :: + * A generic pointer to a variable or structure that gives the new + * value of the property. The exact definition of `value' is + * dependent on the property; see the `Synopsis' subsection of the + * module's documentation. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name' isn't a valid module name, or `property_name' + * doesn't specify a valid property, or if `value' doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example sets property `bar' (a simple integer) in + * module `foo' to value~1. + * + * { + * FT_UInt bar; + * + * + * bar = 1; + * FT_Property_Set( library, "foo", "bar", &bar ); + * } + * + * Note that the FreeType Cache sub-system doesn't recognize module + * property changes. To avoid glyph lookup confusion within the cache + * you should call @FTC_Manager_Reset to completely flush the cache if + * a module property gets changed after @FTC_Manager_New has been + * called. + * + * It is not possible to set properties of the FreeType Cache + * sub-system itself with FT_Property_Set; use @FTC_Property_Set + * instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + const void* value ); + + + /********************************************************************** + * + * @function: + * FT_Property_Get + * + * @description: + * Get a module's property value. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in the `Synopsis' + * subsection of the module's documentation. + * + * @inout: + * value :: + * A generic pointer to a variable or structure that gives the + * value of the property. The exact definition of `value' is + * dependent on the property; see the `Synopsis' subsection of the + * module's documentation. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name' isn't a valid module name, or `property_name' + * doesn't specify a valid property, or if `value' doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example gets property `baz' (a range) in module `foo'. + * + * { + * typedef range_ + * { + * FT_Int32 min; + * FT_Int32 max; + * + * } range; + * + * range baz; + * + * + * FT_Property_Get( library, "foo", "baz", &baz ); + * } + * + * It is not possible to retrieve properties of the FreeType Cache + * sub-system with FT_Property_Get; use @FTC_Property_Get instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Get( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + void* value ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Reference_Library */ + /* */ + /* <Description> */ + /* A counter gets initialized to~1 at the time an @FT_Library */ + /* structure is created. This function increments the counter. */ + /* @FT_Done_Library then only destroys a library if the counter is~1, */ + /* otherwise it simply decrements the counter. */ + /* */ + /* This function helps in managing life-cycles of structures that */ + /* reference @FT_Library objects. */ + /* */ + /* <Input> */ + /* library :: A handle to a target library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.4.2 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Reference_Library( FT_Library library ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Library */ + /* */ + /* <Description> */ + /* This function is used to create a new FreeType library instance */ + /* from a given memory object. It is thus possible to use libraries */ + /* with distinct memory allocators within the same program. Note, */ + /* however, that the used @FT_Memory structure is expected to remain */ + /* valid for the life of the @FT_Library object. */ + /* */ + /* Normally, you would call this function (followed by a call to */ + /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */ + /* instead of @FT_Init_FreeType to initialize the FreeType library. */ + /* */ + /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ + /* library instance. */ + /* */ + /* <Input> */ + /* memory :: A handle to the original memory object. */ + /* */ + /* <Output> */ + /* alibrary :: A pointer to handle of a new library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Library. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Library( FT_Memory memory, + FT_Library *alibrary ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Library */ + /* */ + /* <Description> */ + /* Discard a given library object. This closes all drivers and */ + /* discards all resource objects. */ + /* */ + /* <Input> */ + /* library :: A handle to the target library. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Library. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Library( FT_Library library ); + + /* */ + + typedef void + (*FT_DebugHook_Func)( void* arg ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Debug_Hook */ + /* */ + /* <Description> */ + /* Set a debug hook function for debugging the interpreter of a font */ + /* format. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* hook_index :: The index of the debug hook. You should use the */ + /* values defined in `ftobjs.h', e.g., */ + /* `FT_DEBUG_HOOK_TRUETYPE'. */ + /* */ + /* debug_hook :: The function used to debug the interpreter. */ + /* */ + /* <Note> */ + /* Currently, four debug hook slots are available, but only two (for */ + /* the TrueType and the Type~1 interpreter) are defined. */ + /* */ + /* Since the internal headers of FreeType are no longer installed, */ + /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ + /* This is a bug and will be fixed in a forthcoming release. */ + /* */ + FT_EXPORT( void ) + FT_Set_Debug_Hook( FT_Library library, + FT_UInt hook_index, + FT_DebugHook_Func debug_hook ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Add_Default_Modules */ + /* */ + /* <Description> */ + /* Add the set of default drivers to a given library object. */ + /* This is only useful when you create a library object with */ + /* @FT_New_Library (usually to plug a custom memory manager). */ + /* */ + /* <InOut> */ + /* library :: A handle to a new library object. */ + /* */ + FT_EXPORT( void ) + FT_Add_Default_Modules( FT_Library library ); + + + + /************************************************************************** + * + * @section: + * truetype_engine + * + * @title: + * The TrueType Engine + * + * @abstract: + * TrueType bytecode support. + * + * @description: + * This section contains a function used to query the level of TrueType + * bytecode support compiled in this version of the library. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_TrueTypeEngineType + * + * @description: + * A list of values describing which kind of TrueType bytecode + * engine is implemented in a given FT_Library instance. It is used + * by the @FT_Get_TrueType_Engine_Type function. + * + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. + * + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * Deprecated and removed. + * + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers + * the full instruction set of the TrueType virtual machine (this + * was governed by patents until May 2010, hence the name). + * + * @since: + * 2.2 + * + */ + typedef enum FT_TrueTypeEngineType_ + { + FT_TRUETYPE_ENGINE_TYPE_NONE = 0, + FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, + FT_TRUETYPE_ENGINE_TYPE_PATENTED + + } FT_TrueTypeEngineType; + + + /************************************************************************** + * + * @func: + * FT_Get_TrueType_Engine_Type + * + * @description: + * Return an @FT_TrueTypeEngineType value to indicate which level of + * the TrueType virtual machine a given library instance supports. + * + * @input: + * library :: + * A library instance. + * + * @return: + * A value indicating which level is supported. + * + * @since: + * 2.2 + * + */ + FT_EXPORT( FT_TrueTypeEngineType ) + FT_Get_TrueType_Engine_Type( FT_Library library ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMODAPI_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftmoderr.h b/foreign/freetype2/freetype/ftmoderr.h new file mode 100644 index 0000000..2a7671c --- /dev/null +++ b/foreign/freetype2/freetype/ftmoderr.h @@ -0,0 +1,194 @@ +/***************************************************************************/ +/* */ +/* ftmoderr.h */ +/* */ +/* FreeType module error offsets (specification). */ +/* */ +/* Copyright 2001-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file is used to define the FreeType module error codes. */ + /* */ + /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ + /* set, the lower byte of an error value identifies the error code as */ + /* usual. In addition, the higher byte identifies the module. For */ + /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ + /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ + /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ + /* */ + /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ + /* including the high byte. */ + /* */ + /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ + /* an error value is set to zero. */ + /* */ + /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ + /* provides some macros in `fttypes.h'. */ + /* */ + /* FT_ERR( err ) */ + /* Add current error module prefix (as defined with the */ + /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ + /* the line */ + /* */ + /* error = FT_ERR( Invalid_Outline ); */ + /* */ + /* expands to */ + /* */ + /* error = BDF_Err_Invalid_Outline; */ + /* */ + /* For simplicity, you can always use `FT_Err_Ok' directly instead */ + /* of `FT_ERR( Ok )'. */ + /* */ + /* FT_ERR_EQ( errcode, err ) */ + /* FT_ERR_NEQ( errcode, err ) */ + /* Compare error code `errcode' with the error `err' for equality */ + /* and inequality, respectively. Example: */ + /* */ + /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ + /* ... */ + /* */ + /* Using this macro you don't have to think about error prefixes. */ + /* Of course, if module errors are not active, the above example is */ + /* the same as */ + /* */ + /* if ( error == FT_Err_Invalid_Outline ) */ + /* ... */ + /* */ + /* FT_ERROR_BASE( errcode ) */ + /* FT_ERROR_MODULE( errcode ) */ + /* Get base error and module error code, respectively. */ + /* */ + /* */ + /* It can also be used to create a module error message table easily */ + /* with something like */ + /* */ + /* { */ + /* #undef FTMODERR_H_ */ + /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ + /* #define FT_MODERR_START_LIST { */ + /* #define FT_MODERR_END_LIST { 0, 0 } }; */ + /* */ + /* const struct */ + /* { */ + /* int mod_err_offset; */ + /* const char* mod_err_msg */ + /* } ft_mod_errors[] = */ + /* */ + /* #include FT_MODULE_ERRORS_H */ + /* } */ + /* */ + /*************************************************************************/ + + +#ifndef FTMODERR_H_ +#define FTMODERR_H_ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + +#ifndef FT_MODERRDEF + +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, +#else +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, +#endif + +#define FT_MODERR_START_LIST enum { +#define FT_MODERR_END_LIST FT_Mod_Err_Max }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_MODERRDEF */ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** LIST MODULE ERROR BASES *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_MODERR_START_LIST + FT_MODERR_START_LIST +#endif + + + FT_MODERRDEF( Base, 0x000, "base module" ) + FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) + FT_MODERRDEF( BDF, 0x200, "BDF module" ) + FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) + FT_MODERRDEF( Cache, 0x400, "cache module" ) + FT_MODERRDEF( CFF, 0x500, "CFF module" ) + FT_MODERRDEF( CID, 0x600, "CID module" ) + FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) + FT_MODERRDEF( LZW, 0x800, "LZW module" ) + FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) + FT_MODERRDEF( PCF, 0xA00, "PCF module" ) + FT_MODERRDEF( PFR, 0xB00, "PFR module" ) + FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) + FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) + FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) + FT_MODERRDEF( Raster, 0xF00, "raster module" ) + FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) + FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) + FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) + FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) + FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) + FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) + FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) + + +#ifdef FT_MODERR_END_LIST + FT_MODERR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_MODERR_START_LIST +#undef FT_MODERR_END_LIST +#undef FT_MODERRDEF +#undef FT_NEED_EXTERN_C + + +#endif /* FTMODERR_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftotval.h b/foreign/freetype2/freetype/ftotval.h new file mode 100644 index 0000000..c678ef3 --- /dev/null +++ b/foreign/freetype2/freetype/ftotval.h @@ -0,0 +1,204 @@ +/***************************************************************************/ +/* */ +/* ftotval.h */ +/* */ +/* FreeType API for validating OpenType tables (specification). */ +/* */ +/* Copyright 2004-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* */ +/* Warning: This module might be moved to a different library in the */ +/* future to avoid a tight dependency between FreeType and the */ +/* OpenType specification. */ +/* */ +/* */ +/***************************************************************************/ + + +#ifndef FTOTVAL_H_ +#define FTOTVAL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* ot_validation */ + /* */ + /* <Title> */ + /* OpenType Validation */ + /* */ + /* <Abstract> */ + /* An API to validate OpenType tables. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions to validate */ + /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ + /* */ + /* <Order> */ + /* FT_OpenType_Validate */ + /* FT_OpenType_Free */ + /* */ + /* FT_VALIDATE_OTXXX */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_OTXXX + * + * @description: + * A list of bit-field constants used with @FT_OpenType_Validate to + * indicate which OpenType tables should be validated. + * + * @values: + * FT_VALIDATE_BASE :: + * Validate BASE table. + * + * FT_VALIDATE_GDEF :: + * Validate GDEF table. + * + * FT_VALIDATE_GPOS :: + * Validate GPOS table. + * + * FT_VALIDATE_GSUB :: + * Validate GSUB table. + * + * FT_VALIDATE_JSTF :: + * Validate JSTF table. + * + * FT_VALIDATE_MATH :: + * Validate MATH table. + * + * FT_VALIDATE_OT :: + * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + */ +#define FT_VALIDATE_BASE 0x0100 +#define FT_VALIDATE_GDEF 0x0200 +#define FT_VALIDATE_GPOS 0x0400 +#define FT_VALIDATE_GSUB 0x0800 +#define FT_VALIDATE_JSTF 0x1000 +#define FT_VALIDATE_MATH 0x2000 + +#define FT_VALIDATE_OT FT_VALIDATE_BASE | \ + FT_VALIDATE_GDEF | \ + FT_VALIDATE_GPOS | \ + FT_VALIDATE_GSUB | \ + FT_VALIDATE_JSTF | \ + FT_VALIDATE_MATH + + /********************************************************************** + * + * @function: + * FT_OpenType_Validate + * + * @description: + * Validate various OpenType tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without + * error checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_OTXXX for possible values. + * + * @output: + * BASE_table :: + * A pointer to the BASE table. + * + * GDEF_table :: + * A pointer to the GDEF table. + * + * GPOS_table :: + * A pointer to the GPOS table. + * + * GSUB_table :: + * A pointer to the GSUB table. + * + * JSTF_table :: + * A pointer to the JSTF table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with OpenType fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the five tables with + * @FT_OpenType_Free. A NULL value indicates that the table either + * doesn't exist in the font, or the application hasn't asked for + * validation. + */ + FT_EXPORT( FT_Error ) + FT_OpenType_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *BASE_table, + FT_Bytes *GDEF_table, + FT_Bytes *GPOS_table, + FT_Bytes *GSUB_table, + FT_Bytes *JSTF_table ); + + /********************************************************************** + * + * @function: + * FT_OpenType_Free + * + * @description: + * Free the buffer allocated by OpenType validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_OpenType_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_OpenType_Validate only. + */ + FT_EXPORT( void ) + FT_OpenType_Free( FT_Face face, + FT_Bytes table ); + + /* */ + + +FT_END_HEADER + +#endif /* FTOTVAL_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftoutln.h b/foreign/freetype2/freetype/ftoutln.h new file mode 100644 index 0000000..6a64512 --- /dev/null +++ b/foreign/freetype2/freetype/ftoutln.h @@ -0,0 +1,574 @@ +/***************************************************************************/ +/* */ +/* ftoutln.h */ +/* */ +/* Support for the FT_Outline type used to store glyph shapes of */ +/* most scalable font formats (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTOUTLN_H_ +#define FTOUTLN_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /* <Title> */ + /* Outline Processing */ + /* */ + /* <Abstract> */ + /* Functions to create, transform, and render vectorial glyph images. */ + /* */ + /* <Description> */ + /* This section contains routines used to create and destroy scalable */ + /* glyph images known as `outlines'. These can also be measured, */ + /* transformed, and converted into bitmaps and pixmaps. */ + /* */ + /* <Order> */ + /* FT_Outline */ + /* FT_Outline_New */ + /* FT_Outline_Done */ + /* FT_Outline_Copy */ + /* FT_Outline_Translate */ + /* FT_Outline_Transform */ + /* FT_Outline_Embolden */ + /* FT_Outline_EmboldenXY */ + /* FT_Outline_Reverse */ + /* FT_Outline_Check */ + /* */ + /* FT_Outline_Get_CBox */ + /* FT_Outline_Get_BBox */ + /* */ + /* FT_Outline_Get_Bitmap */ + /* FT_Outline_Render */ + /* FT_Outline_Decompose */ + /* FT_Outline_Funcs */ + /* FT_Outline_MoveToFunc */ + /* FT_Outline_LineToFunc */ + /* FT_Outline_ConicToFunc */ + /* FT_Outline_CubicToFunc */ + /* */ + /* FT_Orientation */ + /* FT_Outline_Get_Orientation */ + /* */ + /* FT_OUTLINE_XXX */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Decompose */ + /* */ + /* <Description> */ + /* Walk over an outline's structure to decompose it into individual */ + /* segments and Bézier arcs. This function also emits `move to' */ + /* operations to indicate the start of new contours in the outline. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source target. */ + /* */ + /* func_interface :: A table of `emitters', i.e., function pointers */ + /* called during decomposition to indicate path */ + /* operations. */ + /* */ + /* <InOut> */ + /* user :: A typeless pointer that is passed to each */ + /* emitter during the decomposition. It can be */ + /* used to store the state during the */ + /* decomposition. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* A contour that contains a single point only is represented by a */ + /* `move to' operation followed by `line to' to the same point. In */ + /* most cases, it is best to filter this out before using the */ + /* outline for stroking purposes (otherwise it would result in a */ + /* visible dot when round caps are used). */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Decompose( FT_Outline* outline, + const FT_Outline_Funcs* func_interface, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_New */ + /* */ + /* <Description> */ + /* Create a new outline of a given size. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object from where the */ + /* outline is allocated. Note however that the new */ + /* outline will *not* necessarily be *freed*, when */ + /* destroying the library, by @FT_Done_FreeType. */ + /* */ + /* numPoints :: The maximum number of points within the outline. */ + /* Must be smaller than or equal to 0xFFFF (65535). */ + /* */ + /* numContours :: The maximum number of contours within the outline. */ + /* This value must be in the range 0 to `numPoints'. */ + /* */ + /* <Output> */ + /* anoutline :: A handle to the new outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The reason why this function takes a `library' parameter is simply */ + /* to use the library's memory allocator. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_New( FT_Library library, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ); + + + FT_EXPORT( FT_Error ) + FT_Outline_New_Internal( FT_Memory memory, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Done */ + /* */ + /* <Description> */ + /* Destroy an outline created with @FT_Outline_New. */ + /* */ + /* <Input> */ + /* library :: A handle of the library object used to allocate the */ + /* outline. */ + /* */ + /* outline :: A pointer to the outline object to be discarded. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If the outline's `owner' field is not set, only the outline */ + /* descriptor will be released. */ + /* */ + /* The reason why this function takes an `library' parameter is */ + /* simply to use ft_mem_free(). */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Done( FT_Library library, + FT_Outline* outline ); + + + FT_EXPORT( FT_Error ) + FT_Outline_Done_Internal( FT_Memory memory, + FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Check */ + /* */ + /* <Description> */ + /* Check the contents of an outline descriptor. */ + /* */ + /* <Input> */ + /* outline :: A handle to a source outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Check( FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_CBox */ + /* */ + /* <Description> */ + /* Return an outline's `control box'. The control box encloses all */ + /* the outline's points, including Bézier control points. Though it */ + /* coincides with the exact bounding box for most glyphs, it can be */ + /* slightly larger in some situations (like when rotating an outline */ + /* that contains Bézier outside arcs). */ + /* */ + /* Computing the control box is very fast, while getting the bounding */ + /* box can take much more time as it needs to walk over all segments */ + /* and arcs in the outline. To get the latter, you can use the */ + /* `ftbbox' component, which is dedicated to this single task. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <Output> */ + /* acbox :: The outline's control box. */ + /* */ + /* <Note> */ + /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Get_CBox( const FT_Outline* outline, + FT_BBox *acbox ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Translate */ + /* */ + /* <Description> */ + /* Apply a simple translation to the points of an outline. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Input> */ + /* xOffset :: The horizontal offset. */ + /* */ + /* yOffset :: The vertical offset. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Translate( const FT_Outline* outline, + FT_Pos xOffset, + FT_Pos yOffset ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Copy */ + /* */ + /* <Description> */ + /* Copy an outline into another one. Both objects must have the */ + /* same sizes (number of points & number of contours) when this */ + /* function is called. */ + /* */ + /* <Input> */ + /* source :: A handle to the source outline. */ + /* */ + /* <Output> */ + /* target :: A handle to the target outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Copy( const FT_Outline* source, + FT_Outline *target ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Transform */ + /* */ + /* <Description> */ + /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ + /* for applying rotations, slanting, flipping, etc. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the transformation matrix. */ + /* */ + /* <Note> */ + /* You can use @FT_Outline_Translate if you need to translate the */ + /* outline's points. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Transform( const FT_Outline* outline, + const FT_Matrix* matrix ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Embolden */ + /* */ + /* <Description> */ + /* Embolden an outline. The new outline will be at most 4~times */ + /* `strength' pixels wider and higher. You may think of the left and */ + /* bottom borders as unchanged. */ + /* */ + /* Negative `strength' values to reduce the outline thickness are */ + /* possible also. */ + /* */ + /* <InOut> */ + /* outline :: A handle to the target outline. */ + /* */ + /* <Input> */ + /* strength :: How strong the glyph is emboldened. Expressed in */ + /* 26.6 pixel format. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The used algorithm to increase or decrease the thickness of the */ + /* glyph doesn't change the number of points; this means that certain */ + /* situations like acute angles or intersections are sometimes */ + /* handled incorrectly. */ + /* */ + /* If you need `better' metrics values you should call */ + /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ + /* */ + /* Example call: */ + /* */ + /* { */ + /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ + /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */ + /* FT_Outline_Embolden( &face->glyph->outline, strength ); */ + /* } */ + /* */ + /* To get meaningful results, font scaling values must be set with */ + /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Embolden( FT_Outline* outline, + FT_Pos strength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_EmboldenXY */ + /* */ + /* <Description> */ + /* Embolden an outline. The new outline will be `xstrength' pixels */ + /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ + /* @FT_Outline_Embolden, which uses the same strength in both */ + /* directions. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_EmboldenXY( FT_Outline* outline, + FT_Pos xstrength, + FT_Pos ystrength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Reverse */ + /* */ + /* <Description> */ + /* Reverse the drawing direction of an outline. This is used to */ + /* ensure consistent fill conventions for mirrored glyphs. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Note> */ + /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ + /* the outline's `flags' field. */ + /* */ + /* It shouldn't be used by a normal client application, unless it */ + /* knows what it is doing. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Reverse( FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_Bitmap */ + /* */ + /* <Description> */ + /* Render an outline within a bitmap. The outline's image is simply */ + /* OR-ed to the target bitmap. */ + /* */ + /* <Input> */ + /* library :: A handle to a FreeType library object. */ + /* */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <InOut> */ + /* abitmap :: A pointer to the target bitmap descriptor. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function does NOT CREATE the bitmap, it only renders an */ + /* outline image within the one you pass to it! Consequently, the */ + /* various fields in `abitmap' should be set accordingly. */ + /* */ + /* It will use the raster corresponding to the default glyph format. */ + /* */ + /* The value of the `num_grays' field in `abitmap' is ignored. If */ + /* you select the gray-level rasterizer, and you want less than 256 */ + /* gray levels, you have to use @FT_Outline_Render directly. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_Bitmap( FT_Library library, + FT_Outline* outline, + const FT_Bitmap *abitmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Render */ + /* */ + /* <Description> */ + /* Render an outline within a bitmap using the current scan-convert. */ + /* This function uses an @FT_Raster_Params structure as an argument, */ + /* allowing advanced features like direct composition, translucency, */ + /* etc. */ + /* */ + /* <Input> */ + /* library :: A handle to a FreeType library object. */ + /* */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <InOut> */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ + /* describe the rendering operation. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You should know what you are doing and how @FT_Raster_Params works */ + /* to use this function. */ + /* */ + /* The field `params.source' will be set to `outline' before the scan */ + /* converter is called, which means that the value you give to it is */ + /* actually ignored. */ + /* */ + /* The gray-level rasterizer always uses 256 gray levels. If you */ + /* want less gray levels, you have to provide your own span callback. */ + /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ + /* @FT_Raster_Params structure for more details. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Render( FT_Library library, + FT_Outline* outline, + FT_Raster_Params* params ); + + + /************************************************************************** + * + * @enum: + * FT_Orientation + * + * @description: + * A list of values used to describe an outline's contour orientation. + * + * The TrueType and PostScript specifications use different conventions + * to determine whether outline contours should be filled or unfilled. + * + * @values: + * FT_ORIENTATION_TRUETYPE :: + * According to the TrueType specification, clockwise contours must + * be filled, and counter-clockwise ones must be unfilled. + * + * FT_ORIENTATION_POSTSCRIPT :: + * According to the PostScript specification, counter-clockwise contours + * must be filled, and clockwise ones must be unfilled. + * + * FT_ORIENTATION_FILL_RIGHT :: + * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to + * remember that in TrueType, everything that is to the right of + * the drawing direction of a contour must be filled. + * + * FT_ORIENTATION_FILL_LEFT :: + * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to + * remember that in PostScript, everything that is to the left of + * the drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * + */ + typedef enum FT_Orientation_ + { + FT_ORIENTATION_TRUETYPE = 0, + FT_ORIENTATION_POSTSCRIPT = 1, + FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, + FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, + FT_ORIENTATION_NONE + + } FT_Orientation; + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_Orientation + * + * @description: + * This function analyzes a glyph outline and tries to compute its + * fill orientation (see @FT_Orientation). This is done by integrating + * the total area covered by the outline. The positive integral + * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT + * is returned. The negative integral corresponds to the counter-clockwise + * orientation and @FT_ORIENTATION_TRUETYPE is returned. + * + * Note that this will return @FT_ORIENTATION_TRUETYPE for empty + * outlines. + * + * @input: + * outline :: + * A handle to the source outline. + * + * @return: + * The orientation. + * + */ + FT_EXPORT( FT_Orientation ) + FT_Outline_Get_Orientation( FT_Outline* outline ); + + /* */ + + +FT_END_HEADER + +#endif /* FTOUTLN_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/ftpfr.h b/foreign/freetype2/freetype/ftpfr.h new file mode 100644 index 0000000..2e1bff2 --- /dev/null +++ b/foreign/freetype2/freetype/ftpfr.h @@ -0,0 +1,172 @@ +/***************************************************************************/ +/* */ +/* ftpfr.h */ +/* */ +/* FreeType API for accessing PFR-specific data (specification only). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTPFR_H_ +#define FTPFR_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* pfr_fonts */ + /* */ + /* <Title> */ + /* PFR Fonts */ + /* */ + /* <Abstract> */ + /* PFR/TrueDoc specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of PFR-specific functions. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Metrics + * + * @description: + * Return the outline and metrics resolutions of a given PFR face. + * + * @input: + * face :: Handle to the input face. It can be a non-PFR face. + * + * @output: + * aoutline_resolution :: + * Outline resolution. This is equivalent to `face->units_per_EM' + * for non-PFR fonts. Optional (parameter can be NULL). + * + * ametrics_resolution :: + * Metrics resolution. This is equivalent to `outline_resolution' + * for non-PFR fonts. Optional (parameter can be NULL). + * + * ametrics_x_scale :: + * A 16.16 fixed-point number used to scale distance expressed + * in metrics units to device sub-pixels. This is equivalent to + * `face->size->x_scale', but for metrics only. Optional (parameter + * can be NULL). + * + * ametrics_y_scale :: + * Same as `ametrics_x_scale' but for the vertical direction. + * optional (parameter can be NULL). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the input face is not a PFR, this function will return an error. + * However, in all cases, it will return valid values. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Metrics( FT_Face face, + FT_UInt *aoutline_resolution, + FT_UInt *ametrics_resolution, + FT_Fixed *ametrics_x_scale, + FT_Fixed *ametrics_y_scale ); + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Kerning + * + * @description: + * Return the kerning pair corresponding to two glyphs in a PFR face. + * The distance is expressed in metrics units, unlike the result of + * @FT_Get_Kerning. + * + * @input: + * face :: A handle to the input face. + * + * left :: Index of the left glyph. + * + * right :: Index of the right glyph. + * + * @output: + * avector :: A kerning vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function always return distances in original PFR metrics + * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED + * mode, which always returns distances converted to outline units. + * + * You can use the value of the `x_scale' and `y_scale' parameters + * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Kerning( FT_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ); + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Advance + * + * @description: + * Return a given glyph advance, expressed in original metrics units, + * from a PFR font. + * + * @input: + * face :: A handle to the input face. + * + * gindex :: The glyph index. + * + * @output: + * aadvance :: The glyph advance in metrics units. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics + * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Advance( FT_Face face, + FT_UInt gindex, + FT_Pos *aadvance ); + + /* */ + + +FT_END_HEADER + +#endif /* FTPFR_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftrender.h b/foreign/freetype2/freetype/ftrender.h new file mode 100644 index 0000000..9f7ed9e --- /dev/null +++ b/foreign/freetype2/freetype/ftrender.h @@ -0,0 +1,232 @@ +/***************************************************************************/ +/* */ +/* ftrender.h */ +/* */ +/* FreeType renderer modules public interface (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTRENDER_H_ +#define FTRENDER_H_ + + +#include <ft2build.h> +#include FT_MODULE_H +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /*************************************************************************/ + + + /* create a new glyph object */ + typedef FT_Error + (*FT_Glyph_InitFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + + /* destroys a given glyph object */ + typedef void + (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); + + typedef void + (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + typedef void + (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, + FT_BBox* abbox ); + + typedef FT_Error + (*FT_Glyph_CopyFunc)( FT_Glyph source, + FT_Glyph target ); + + typedef FT_Error + (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + +/* deprecated */ +#define FT_Glyph_Init_Func FT_Glyph_InitFunc +#define FT_Glyph_Done_Func FT_Glyph_DoneFunc +#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc +#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc +#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc +#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc + + + struct FT_Glyph_Class_ + { + FT_Long glyph_size; + FT_Glyph_Format glyph_format; + FT_Glyph_InitFunc glyph_init; + FT_Glyph_DoneFunc glyph_done; + FT_Glyph_CopyFunc glyph_copy; + FT_Glyph_TransformFunc glyph_transform; + FT_Glyph_GetBBoxFunc glyph_bbox; + FT_Glyph_PrepareFunc glyph_prepare; + }; + + + typedef FT_Error + (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_UInt mode, + const FT_Vector* origin ); + + typedef FT_Error + (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + + typedef void + (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_BBox* cbox ); + + + typedef FT_Error + (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, + FT_ULong mode_tag, + FT_Pointer mode_ptr ); + +/* deprecated identifiers */ +#define FTRenderer_render FT_Renderer_RenderFunc +#define FTRenderer_transform FT_Renderer_TransformFunc +#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc +#define FTRenderer_setMode FT_Renderer_SetModeFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Renderer_Class */ + /* */ + /* <Description> */ + /* The renderer module class descriptor. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Module_Class fields. */ + /* */ + /* glyph_format :: The glyph image format this renderer handles. */ + /* */ + /* render_glyph :: A method used to render the image that is in a */ + /* given glyph slot into a bitmap. */ + /* */ + /* transform_glyph :: A method used to transform the image that is in */ + /* a given glyph slot. */ + /* */ + /* get_glyph_cbox :: A method used to access the glyph's cbox. */ + /* */ + /* set_mode :: A method used to pass additional parameters. */ + /* */ + /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ + /* This is a pointer to its raster's class. */ + /* */ + typedef struct FT_Renderer_Class_ + { + FT_Module_Class root; + + FT_Glyph_Format glyph_format; + + FT_Renderer_RenderFunc render_glyph; + FT_Renderer_TransformFunc transform_glyph; + FT_Renderer_GetCBoxFunc get_glyph_cbox; + FT_Renderer_SetModeFunc set_mode; + + FT_Raster_Funcs* raster_class; + + } FT_Renderer_Class; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Renderer */ + /* */ + /* <Description> */ + /* Retrieve the current renderer for a given glyph format. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object. */ + /* */ + /* format :: The glyph format. */ + /* */ + /* <Return> */ + /* A renderer handle. 0~if none found. */ + /* */ + /* <Note> */ + /* An error will be returned if a module already exists by that name, */ + /* or if the module requires a version of FreeType that is too great. */ + /* */ + /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ + /* renderer by its name, use @FT_Get_Module. */ + /* */ + FT_EXPORT( FT_Renderer ) + FT_Get_Renderer( FT_Library library, + FT_Glyph_Format format ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Renderer */ + /* */ + /* <Description> */ + /* Set the current renderer to use, and set additional mode. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* renderer :: A handle to the renderer object. */ + /* */ + /* num_params :: The number of additional parameters. */ + /* */ + /* parameters :: Additional parameters. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* In case of success, the renderer will be used to convert glyph */ + /* images in the renderer's known format into bitmaps. */ + /* */ + /* This doesn't change the current renderer for other formats. */ + /* */ + /* Currently, no FreeType renderer module uses `parameters'; you */ + /* should thus always pass NULL as the value. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Renderer( FT_Library library, + FT_Renderer renderer, + FT_UInt num_params, + FT_Parameter* parameters ); + + /* */ + + +FT_END_HEADER + +#endif /* FTRENDER_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftsizes.h b/foreign/freetype2/freetype/ftsizes.h new file mode 100644 index 0000000..55e0d5c --- /dev/null +++ b/foreign/freetype2/freetype/ftsizes.h @@ -0,0 +1,159 @@ +/***************************************************************************/ +/* */ +/* ftsizes.h */ +/* */ +/* FreeType size objects management (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Typical application would normally not need to use these functions. */ + /* However, they have been placed in a public API for the rare cases */ + /* where they are needed. */ + /* */ + /*************************************************************************/ + + +#ifndef FTSIZES_H_ +#define FTSIZES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* sizes_management */ + /* */ + /* <Title> */ + /* Size Management */ + /* */ + /* <Abstract> */ + /* Managing multiple sizes per face. */ + /* */ + /* <Description> */ + /* When creating a new face object (e.g., with @FT_New_Face), an */ + /* @FT_Size object is automatically created and used to store all */ + /* pixel-size dependent information, available in the `face->size' */ + /* field. */ + /* */ + /* It is however possible to create more sizes for a given face, */ + /* mostly in order to manage several character pixel sizes of the */ + /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ + /* */ + /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ + /* modify the contents of the current `active' size; you thus need */ + /* to use @FT_Activate_Size to change it. */ + /* */ + /* 99% of applications won't need the functions provided here, */ + /* especially if they use the caching sub-system, so be cautious */ + /* when using these. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Size */ + /* */ + /* <Description> */ + /* Create a new size object from a given face object. */ + /* */ + /* <Input> */ + /* face :: A handle to a parent face object. */ + /* */ + /* <Output> */ + /* asize :: A handle to a new size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You need to call @FT_Activate_Size in order to select the new size */ + /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ + /* @FT_Load_Glyph, @FT_Load_Char, etc. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Size( FT_Face face, + FT_Size* size ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Size */ + /* */ + /* <Description> */ + /* Discard a given size object. Note that @FT_Done_Face */ + /* automatically discards all size objects allocated with */ + /* @FT_New_Size. */ + /* */ + /* <Input> */ + /* size :: A handle to a target size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Size( FT_Size size ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Activate_Size */ + /* */ + /* <Description> */ + /* Even though it is possible to create several size objects for a */ + /* given face (see @FT_New_Size for details), functions like */ + /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ + /* activated last to determine the `current character pixel size'. */ + /* */ + /* This function can be used to `activate' a previously created size */ + /* object. */ + /* */ + /* <Input> */ + /* size :: A handle to a target size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If `face' is the size's parent face object, this function changes */ + /* the value of `face->size' to the input size handle. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Activate_Size( FT_Size size ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSIZES_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftsnames.h b/foreign/freetype2/freetype/ftsnames.h new file mode 100644 index 0000000..a7b51c2 --- /dev/null +++ b/foreign/freetype2/freetype/ftsnames.h @@ -0,0 +1,200 @@ +/***************************************************************************/ +/* */ +/* ftsnames.h */ +/* */ +/* Simple interface to access SFNT name tables (which are used */ +/* to hold font names, copyright info, notices, etc.) (specification). */ +/* */ +/* This is _not_ used to retrieve glyph names! */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSNAMES_H_ +#define FTSNAMES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* sfnt_names */ + /* */ + /* <Title> */ + /* SFNT Names */ + /* */ + /* <Abstract> */ + /* Access the names embedded in TrueType and OpenType files. */ + /* */ + /* <Description> */ + /* The TrueType and OpenType specifications allow the inclusion of */ + /* a special `names table' in font files. This table contains */ + /* textual (and internationalized) information regarding the font, */ + /* like family name, copyright, version, etc. */ + /* */ + /* The definitions below are used to access them if available. */ + /* */ + /* Note that this has nothing to do with glyph names! */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SfntName */ + /* */ + /* <Description> */ + /* A structure used to model an SFNT `name' table entry. */ + /* */ + /* <Fields> */ + /* platform_id :: The platform ID for `string'. */ + /* */ + /* encoding_id :: The encoding ID for `string'. */ + /* */ + /* language_id :: The language ID for `string'. */ + /* */ + /* name_id :: An identifier for `string'. */ + /* */ + /* string :: The `name' string. Note that its format differs */ + /* depending on the (platform,encoding) pair. It can */ + /* be a Pascal String, a UTF-16 one, etc. */ + /* */ + /* Generally speaking, the string is not */ + /* zero-terminated. Please refer to the TrueType */ + /* specification for details. */ + /* */ + /* string_len :: The length of `string' in bytes. */ + /* */ + /* <Note> */ + /* Possible values for `platform_id', `encoding_id', `language_id', */ + /* and `name_id' are given in the file `ttnameid.h'. For details */ + /* please refer to the TrueType or OpenType specification. */ + /* */ + /* See also @TT_PLATFORM_XXX, @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ + /* @TT_ISO_ID_XXX, and @TT_MS_ID_XXX. */ + /* */ + typedef struct FT_SfntName_ + { + FT_UShort platform_id; + FT_UShort encoding_id; + FT_UShort language_id; + FT_UShort name_id; + + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntName; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Name_Count */ + /* */ + /* <Description> */ + /* Retrieve the number of name strings in the SFNT `name' table. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Return> */ + /* The number of strings in the `name' table. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Name */ + /* */ + /* <Description> */ + /* Retrieve a string of the SFNT `name' table for a given index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* idx :: The index of the `name' string. */ + /* */ + /* <Output> */ + /* aname :: The indexed @FT_SfntName structure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `string' array returned in the `aname' structure is not */ + /* null-terminated. The application should deallocate it if it is no */ + /* longer in use. */ + /* */ + /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ + /* `name' table entries, then do a loop until you get the right */ + /* platform, encoding, and name ID. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ); + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY + * + * @description: + * A constant used as the tag of @FT_Parameter structures to make + * FT_Open_Face() ignore preferred family subfamily names in `name' + * table since OpenType version 1.4. For backwards compatibility with + * legacy systems that have a 4-face-per-family restriction. + * + */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY + * + * @description: + * A constant used as the tag of @FT_Parameter structures to make + * FT_Open_Face() ignore preferred subfamily names in `name' table since + * OpenType version 1.4. For backwards compatibility with legacy + * systems that have a 4-face-per-family restriction. + * + */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + + /* */ + + +FT_END_HEADER + +#endif /* FTSNAMES_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftstroke.h b/foreign/freetype2/freetype/ftstroke.h new file mode 100644 index 0000000..b3b9922 --- /dev/null +++ b/foreign/freetype2/freetype/ftstroke.h @@ -0,0 +1,785 @@ +/***************************************************************************/ +/* */ +/* ftstroke.h */ +/* */ +/* FreeType path stroker (specification). */ +/* */ +/* Copyright 2002-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSTROKE_H_ +#define FTSTROKE_H_ + +#include <ft2build.h> +#include FT_OUTLINE_H +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /************************************************************************ + * + * @section: + * glyph_stroker + * + * @title: + * Glyph Stroker + * + * @abstract: + * Generating bordered and stroked glyphs. + * + * @description: + * This component generates stroked outlines of a given vectorial + * glyph. It also allows you to retrieve the `outside' and/or the + * `inside' borders of the stroke. + * + * This can be useful to generate `bordered' glyph, i.e., glyphs + * displayed with a coloured (and anti-aliased) border around their + * shape. + * + * @order: + * FT_Stroker + * + * FT_Stroker_LineJoin + * FT_Stroker_LineCap + * FT_StrokerBorder + * + * FT_Outline_GetInsideBorder + * FT_Outline_GetOutsideBorder + * + * FT_Glyph_Stroke + * FT_Glyph_StrokeBorder + * + * FT_Stroker_New + * FT_Stroker_Set + * FT_Stroker_Rewind + * FT_Stroker_ParseOutline + * FT_Stroker_Done + * + * FT_Stroker_BeginSubPath + * FT_Stroker_EndSubPath + * + * FT_Stroker_LineTo + * FT_Stroker_ConicTo + * FT_Stroker_CubicTo + * + * FT_Stroker_GetBorderCounts + * FT_Stroker_ExportBorder + * FT_Stroker_GetCounts + * FT_Stroker_Export + * + */ + + + /************************************************************** + * + * @type: + * FT_Stroker + * + * @description: + * Opaque handle to a path stroker object. + */ + typedef struct FT_StrokerRec_* FT_Stroker; + + + /************************************************************** + * + * @enum: + * FT_Stroker_LineJoin + * + * @description: + * These values determine how two joining lines are rendered + * in a stroker. + * + * @values: + * FT_STROKER_LINEJOIN_ROUND :: + * Used to render rounded line joins. Circular arcs are used + * to join two lines smoothly. + * + * FT_STROKER_LINEJOIN_BEVEL :: + * Used to render beveled line joins. The outer corner of + * the joined lines is filled by enclosing the triangular + * region of the corner with a straight line between the + * outer corners of each stroke. + * + * FT_STROKER_LINEJOIN_MITER_FIXED :: + * Used to render mitered line joins, with fixed bevels if the + * miter limit is exceeded. The outer edges of the strokes + * for the two segments are extended until they meet at an + * angle. If the segments meet at too sharp an angle (such + * that the miter would extend from the intersection of the + * segments a distance greater than the product of the miter + * limit value and the border radius), then a bevel join (see + * above) is used instead. This prevents long spikes being + * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter + * line join as used in PostScript and PDF. + * + * FT_STROKER_LINEJOIN_MITER_VARIABLE :: + * FT_STROKER_LINEJOIN_MITER :: + * Used to render mitered line joins, with variable bevels if + * the miter limit is exceeded. The intersection of the + * strokes is clipped at a line perpendicular to the bisector + * of the angle between the strokes, at the distance from the + * intersection of the segments equal to the product of the + * miter limit value and the border radius. This prevents + * long spikes being created. + * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line + * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias + * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for + * backwards compatibility. + */ + typedef enum FT_Stroker_LineJoin_ + { + FT_STROKER_LINEJOIN_ROUND = 0, + FT_STROKER_LINEJOIN_BEVEL = 1, + FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, + FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE, + FT_STROKER_LINEJOIN_MITER_FIXED = 3 + + } FT_Stroker_LineJoin; + + + /************************************************************** + * + * @enum: + * FT_Stroker_LineCap + * + * @description: + * These values determine how the end of opened sub-paths are + * rendered in a stroke. + * + * @values: + * FT_STROKER_LINECAP_BUTT :: + * The end of lines is rendered as a full stop on the last + * point itself. + * + * FT_STROKER_LINECAP_ROUND :: + * The end of lines is rendered as a half-circle around the + * last point. + * + * FT_STROKER_LINECAP_SQUARE :: + * The end of lines is rendered as a square around the + * last point. + */ + typedef enum FT_Stroker_LineCap_ + { + FT_STROKER_LINECAP_BUTT = 0, + FT_STROKER_LINECAP_ROUND, + FT_STROKER_LINECAP_SQUARE + + } FT_Stroker_LineCap; + + + /************************************************************** + * + * @enum: + * FT_StrokerBorder + * + * @description: + * These values are used to select a given stroke border + * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. + * + * @values: + * FT_STROKER_BORDER_LEFT :: + * Select the left border, relative to the drawing direction. + * + * FT_STROKER_BORDER_RIGHT :: + * Select the right border, relative to the drawing direction. + * + * @note: + * Applications are generally interested in the `inside' and `outside' + * borders. However, there is no direct mapping between these and the + * `left' and `right' ones, since this really depends on the glyph's + * drawing orientation, which varies between font formats. + * + * You can however use @FT_Outline_GetInsideBorder and + * @FT_Outline_GetOutsideBorder to get these. + */ + typedef enum FT_StrokerBorder_ + { + FT_STROKER_BORDER_LEFT = 0, + FT_STROKER_BORDER_RIGHT + + } FT_StrokerBorder; + + + /************************************************************** + * + * @function: + * FT_Outline_GetInsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the + * `inside' borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetInsideBorder( FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Outline_GetOutsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the + * `outside' borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetOutsideBorder( FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_New + * + * @description: + * Create a new stroker object. + * + * @input: + * library :: + * FreeType library handle. + * + * @output: + * astroker :: + * A new stroker object handle. NULL in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_New( FT_Library library, + FT_Stroker *astroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Set + * + * @description: + * Reset a stroker object's attributes. + * + * @input: + * stroker :: + * The target stroker handle. + * + * radius :: + * The border radius. + * + * line_cap :: + * The line cap style. + * + * line_join :: + * The line join style. + * + * miter_limit :: + * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and + * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, + * expressed as 16.16 fixed-point value. + * + * @note: + * The radius is expressed in the same units as the outline + * coordinates. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( void ) + FT_Stroker_Set( FT_Stroker stroker, + FT_Fixed radius, + FT_Stroker_LineCap line_cap, + FT_Stroker_LineJoin line_join, + FT_Fixed miter_limit ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Rewind + * + * @description: + * Reset a stroker object without changing its attributes. + * You should call this function before beginning a new + * series of calls to @FT_Stroker_BeginSubPath or + * @FT_Stroker_EndSubPath. + * + * @input: + * stroker :: + * The target stroker handle. + */ + FT_EXPORT( void ) + FT_Stroker_Rewind( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ParseOutline + * + * @description: + * A convenience function used to parse a whole outline with + * the stroker. The resulting outline(s) can be retrieved + * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The source outline. + * + * opened :: + * A boolean. If~1, the outline is treated as an open path instead + * of a closed one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `opened' is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct `border' outlines. + * + * If `opened' is~1, the outline is processed as an open path, and the + * stroker generates a single `stroke' outline. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ParseOutline( FT_Stroker stroker, + FT_Outline* outline, + FT_Bool opened ); + + + /************************************************************** + * + * @function: + * FT_Stroker_BeginSubPath + * + * @description: + * Start a new sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the start vector. + * + * open :: + * A boolean. If~1, the sub-path is treated as an open one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is useful when you need to stroke a path that is + * not stored as an @FT_Outline object. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_BeginSubPath( FT_Stroker stroker, + FT_Vector* to, + FT_Bool open ); + + + /************************************************************** + * + * @function: + * FT_Stroker_EndSubPath + * + * @description: + * Close the current sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function after @FT_Stroker_BeginSubPath. + * If the subpath was not `opened', this function `draws' a + * single line segment to the start position when needed. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_EndSubPath( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_LineTo + * + * @description: + * `Draw' a single line segment in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_LineTo( FT_Stroker stroker, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ConicTo + * + * @description: + * `Draw' a single quadratic Bézier in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control :: + * A pointer to a Bézier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ConicTo( FT_Stroker stroker, + FT_Vector* control, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_CubicTo + * + * @description: + * `Draw' a single cubic Bézier in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control1 :: + * A pointer to the first Bézier control point. + * + * control2 :: + * A pointer to second Bézier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_CubicTo( FT_Stroker stroker, + FT_Vector* control1, + FT_Vector* control2, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_GetBorderCounts + * + * @description: + * Call this function once you have finished parsing your paths + * with the stroker. It returns the number of points and + * contours necessary to export one of the `border' or `stroke' + * outlines generated by the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * When an outline, or a sub-path, is `closed', the stroker generates + * two independent `border' outlines, named `left' and `right'. + * + * When the outline, or a sub-path, is `opened', the stroker merges + * the `border' outlines with caps. The `left' border receives all + * points, while the `right' border becomes empty. + * + * Use the function @FT_Stroker_GetCounts instead if you want to + * retrieve the counts associated to both borders. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetBorderCounts( FT_Stroker stroker, + FT_StrokerBorder border, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ExportBorder + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to + * export the corresponding border to your own @FT_Outline + * structure. + * + * Note that this function appends the border points and + * contours to your outline, but does not try to resize its + * arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * outline :: + * The target outline handle. + * + * @note: + * Always call this function after @FT_Stroker_GetBorderCounts to + * get sure that there is enough room in your @FT_Outline object to + * receive all new data. + * + * When an outline, or a sub-path, is `closed', the stroker generates + * two independent `border' outlines, named `left' and `right'. + * + * When the outline, or a sub-path, is `opened', the stroker merges + * the `border' outlines with caps. The `left' border receives all + * points, while the `right' border becomes empty. + * + * Use the function @FT_Stroker_Export instead if you want to + * retrieve all borders at once. + */ + FT_EXPORT( void ) + FT_Stroker_ExportBorder( FT_Stroker stroker, + FT_StrokerBorder border, + FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_GetCounts + * + * @description: + * Call this function once you have finished parsing your paths + * with the stroker. It returns the number of points and + * contours necessary to export all points/borders from the stroked + * outline/path. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetCounts( FT_Stroker stroker, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Export + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to + * export all borders to your own @FT_Outline structure. + * + * Note that this function appends the border points and + * contours to your outline, but does not try to resize its + * arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The target outline handle. + */ + FT_EXPORT( void ) + FT_Stroker_Export( FT_Stroker stroker, + FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Done + * + * @description: + * Destroy a stroker object. + * + * @input: + * stroker :: + * A stroker handle. Can be NULL. + */ + FT_EXPORT( void ) + FT_Stroker_Done( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Glyph_Stroke + * + * @description: + * Stroke a given outline glyph object with a given stroker. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed + * on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts + * to account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_Stroke( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool destroy ); + + + /************************************************************** + * + * @function: + * FT_Glyph_StrokeBorder + * + * @description: + * Stroke a given outline glyph object with a given stroker, but + * only return either its inside or outside border. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * inside :: + * A Boolean. If~1, return the inside border, otherwise + * the outside border. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed + * on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts + * to account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_StrokeBorder( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool inside, + FT_Bool destroy ); + + /* */ + +FT_END_HEADER + +#endif /* FTSTROKE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/ftsynth.h b/foreign/freetype2/freetype/ftsynth.h new file mode 100644 index 0000000..fdfcb69 --- /dev/null +++ b/foreign/freetype2/freetype/ftsynth.h @@ -0,0 +1,84 @@ +/***************************************************************************/ +/* */ +/* ftsynth.h */ +/* */ +/* FreeType synthesizing code for emboldening and slanting */ +/* (specification). */ +/* */ +/* Copyright 2000-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********* *********/ + /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ + /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ + /********* FREETYPE DEVELOPMENT TEAM *********/ + /********* *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* Main reason for not lifting the functions in this module to a */ + /* `standard' API is that the used parameters for emboldening and */ + /* slanting are not configurable. Consider the functions as a */ + /* code resource that should be copied into the application and */ + /* adapted to the particular needs. */ + + +#ifndef FTSYNTH_H_ +#define FTSYNTH_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ + /* taste). This function is actually a convenience function, providing */ + /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ + /* */ + /* For emboldened outlines the height, width, and advance metrics are */ + /* increased by the strength of the emboldening -- this even affects */ + /* mono-width fonts! */ + /* */ + /* You can also call @FT_Outline_Get_CBox to get precise values. */ + FT_EXPORT( void ) + FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); + + /* Slant an outline glyph to the right by about 12 degrees. */ + FT_EXPORT( void ) + FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSYNTH_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftsystem.h b/foreign/freetype2/freetype/ftsystem.h new file mode 100644 index 0000000..908ae07 --- /dev/null +++ b/foreign/freetype2/freetype/ftsystem.h @@ -0,0 +1,355 @@ +/***************************************************************************/ +/* */ +/* ftsystem.h */ +/* */ +/* FreeType low-level system interface definition (specification). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSYSTEM_H_ +#define FTSYSTEM_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* system_interface */ + /* */ + /* <Title> */ + /* System Interface */ + /* */ + /* <Abstract> */ + /* How FreeType manages memory and i/o. */ + /* */ + /* <Description> */ + /* This section contains various definitions related to memory */ + /* management and i/o access. You need to understand this */ + /* information if you want to use a custom memory manager or you own */ + /* i/o streams. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* M E M O R Y M A N A G E M E N T */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Memory + * + * @description: + * A handle to a given memory manager object, defined with an + * @FT_MemoryRec structure. + * + */ + typedef struct FT_MemoryRec_* FT_Memory; + + + /************************************************************************* + * + * @functype: + * FT_Alloc_Func + * + * @description: + * A function used to allocate `size' bytes from `memory'. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * size :: + * The size in bytes to allocate. + * + * @return: + * Address of new memory block. 0~in case of failure. + * + */ + typedef void* + (*FT_Alloc_Func)( FT_Memory memory, + long size ); + + + /************************************************************************* + * + * @functype: + * FT_Free_Func + * + * @description: + * A function used to release a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * block :: + * The address of the target memory block. + * + */ + typedef void + (*FT_Free_Func)( FT_Memory memory, + void* block ); + + + /************************************************************************* + * + * @functype: + * FT_Realloc_Func + * + * @description: + * A function used to re-allocate a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * cur_size :: + * The block's current size in bytes. + * + * new_size :: + * The block's requested new size. + * + * block :: + * The block's current address. + * + * @return: + * New block address. 0~in case of memory shortage. + * + * @note: + * In case of error, the old block must still be available. + * + */ + typedef void* + (*FT_Realloc_Func)( FT_Memory memory, + long cur_size, + long new_size, + void* block ); + + + /************************************************************************* + * + * @struct: + * FT_MemoryRec + * + * @description: + * A structure used to describe a given memory manager to FreeType~2. + * + * @fields: + * user :: + * A generic typeless pointer for user data. + * + * alloc :: + * A pointer type to an allocation function. + * + * free :: + * A pointer type to an memory freeing function. + * + * realloc :: + * A pointer type to a reallocation function. + * + */ + struct FT_MemoryRec_ + { + void* user; + FT_Alloc_Func alloc; + FT_Free_Func free; + FT_Realloc_Func realloc; + }; + + + /*************************************************************************/ + /* */ + /* I / O M A N A G E M E N T */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Stream + * + * @description: + * A handle to an input stream. + * + * @also: + * See @FT_StreamRec for the publicly accessible fields of a given + * stream object. + * + */ + typedef struct FT_StreamRec_* FT_Stream; + + + /************************************************************************* + * + * @struct: + * FT_StreamDesc + * + * @description: + * A union type used to store either a long or a pointer. This is used + * to store a file descriptor or a `FILE*' in an input stream. + * + */ + typedef union FT_StreamDesc_ + { + long value; + void* pointer; + + } FT_StreamDesc; + + + /************************************************************************* + * + * @functype: + * FT_Stream_IoFunc + * + * @description: + * A function used to seek and read data from a given input stream. + * + * @input: + * stream :: + * A handle to the source stream. + * + * offset :: + * The offset of read in stream (always from start). + * + * buffer :: + * The address of the read buffer. + * + * count :: + * The number of bytes to read from the stream. + * + * @return: + * The number of bytes effectively read by the stream. + * + * @note: + * This function might be called to perform a seek or skip operation + * with a `count' of~0. A non-zero return value then indicates an + * error. + * + */ + typedef unsigned long + (*FT_Stream_IoFunc)( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ); + + + /************************************************************************* + * + * @functype: + * FT_Stream_CloseFunc + * + * @description: + * A function used to close a given input stream. + * + * @input: + * stream :: + * A handle to the target stream. + * + */ + typedef void + (*FT_Stream_CloseFunc)( FT_Stream stream ); + + + /************************************************************************* + * + * @struct: + * FT_StreamRec + * + * @description: + * A structure used to describe an input stream. + * + * @input: + * base :: + * For memory-based streams, this is the address of the first stream + * byte in memory. This field should always be set to NULL for + * disk-based streams. + * + * size :: + * The stream size in bytes. + * + * In case of compressed streams where the size is unknown before + * actually doing the decompression, the value is set to 0x7FFFFFFF. + * (Note that this size value can occur for normal streams also; it is + * thus just a hint.) + * + * pos :: + * The current position within the stream. + * + * descriptor :: + * This field is a union that can hold an integer or a pointer. It is + * used by stream implementations to store file descriptors or `FILE*' + * pointers. + * + * pathname :: + * This field is completely ignored by FreeType. However, it is often + * useful during debugging to use it to store the stream's filename + * (where available). + * + * read :: + * The stream's input function. + * + * close :: + * The stream's close function. + * + * memory :: + * The memory manager to use to preload frames. This is set + * internally by FreeType and shouldn't be touched by stream + * implementations. + * + * cursor :: + * This field is set and used internally by FreeType when parsing + * frames. + * + * limit :: + * This field is set and used internally by FreeType when parsing + * frames. + * + */ + typedef struct FT_StreamRec_ + { + unsigned char* base; + unsigned long size; + unsigned long pos; + + FT_StreamDesc descriptor; + FT_StreamDesc pathname; + FT_Stream_IoFunc read; + FT_Stream_CloseFunc close; + + FT_Memory memory; + unsigned char* cursor; + unsigned char* limit; + + } FT_StreamRec; + + /* */ + + +FT_END_HEADER + +#endif /* FTSYSTEM_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/fttrigon.h b/foreign/freetype2/freetype/fttrigon.h new file mode 100644 index 0000000..f789b52 --- /dev/null +++ b/foreign/freetype2/freetype/fttrigon.h @@ -0,0 +1,350 @@ +/***************************************************************************/ +/* */ +/* fttrigon.h */ +/* */ +/* FreeType trigonometric functions (specification). */ +/* */ +/* Copyright 2001-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTTRIGON_H_ +#define FTTRIGON_H_ + +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Angle + * + * @description: + * This type is used to model angle values in FreeType. Note that the + * angle is a 16.16 fixed-point value expressed in degrees. + * + */ + typedef FT_Fixed FT_Angle; + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI + * + * @description: + * The angle pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI ( 180L << 16 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_2PI + * + * @description: + * The angle 2*pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI2 + * + * @description: + * The angle pi/2 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI4 + * + * @description: + * The angle pi/4 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) + + + /************************************************************************* + * + * @function: + * FT_Sin + * + * @description: + * Return the sinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The sinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Sin( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Cos + * + * @description: + * Return the cosinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The cosinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Cos( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Tan + * + * @description: + * Return the tangent of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The tangent value. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Tan( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Atan2 + * + * @description: + * Return the arc-tangent corresponding to a given vector (x,y) in + * the 2d plane. + * + * @input: + * x :: + * The horizontal vector coordinate. + * + * y :: + * The vertical vector coordinate. + * + * @return: + * The arc-tangent value (i.e. angle). + * + */ + FT_EXPORT( FT_Angle ) + FT_Atan2( FT_Fixed x, + FT_Fixed y ); + + + /************************************************************************* + * + * @function: + * FT_Angle_Diff + * + * @description: + * Return the difference between two angles. The result is always + * constrained to the ]-PI..PI] interval. + * + * @input: + * angle1 :: + * First angle. + * + * angle2 :: + * Second angle. + * + * @return: + * Constrained value of `value2-value1'. + * + */ + FT_EXPORT( FT_Angle ) + FT_Angle_Diff( FT_Angle angle1, + FT_Angle angle2 ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Unit + * + * @description: + * Return the unit vector corresponding to a given angle. After the + * call, the value of `vec.x' will be `cos(angle)', and the value of + * `vec.y' will be `sin(angle)'. + * + * This function is useful to retrieve both the sinus and cosinus of a + * given angle quickly. + * + * @output: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Unit( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Rotate + * + * @description: + * Rotate a vector by a given angle. + * + * @inout: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Rotate( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Length + * + * @description: + * Return the length of a given vector. + * + * @input: + * vec :: + * The address of target vector. + * + * @return: + * The vector length, expressed in the same units that the original + * vector coordinates. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Vector_Length( FT_Vector* vec ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Polarize + * + * @description: + * Compute both the length and angle of a given vector. + * + * @input: + * vec :: + * The address of source vector. + * + * @output: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Polarize( FT_Vector* vec, + FT_Fixed *length, + FT_Angle *angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_From_Polar + * + * @description: + * Compute vector coordinates from a length and angle. + * + * @output: + * vec :: + * The address of source vector. + * + * @input: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_From_Polar( FT_Vector* vec, + FT_Fixed length, + FT_Angle angle ); + + /* */ + + +FT_END_HEADER + +#endif /* FTTRIGON_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftttdrv.h b/foreign/freetype2/freetype/ftttdrv.h new file mode 100644 index 0000000..6c02e65 --- /dev/null +++ b/foreign/freetype2/freetype/ftttdrv.h @@ -0,0 +1,310 @@ +/***************************************************************************/ +/* */ +/* ftttdrv.h */ +/* */ +/* FreeType API for controlling the TrueType driver */ +/* (specification only). */ +/* */ +/* Copyright 2013-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTTTDRV_H_ +#define FTTTDRV_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * tt_driver + * + * @title: + * The TrueType driver + * + * @abstract: + * Controlling the TrueType driver module. + * + * @description: + * While FreeType's TrueType driver doesn't expose API functions by + * itself, it is possible to control its behaviour with @FT_Property_Set + * and @FT_Property_Get. The following lists the available properties + * together with the necessary macros and structures. + * + * The TrueType driver's module name is `truetype'. + * + * We start with a list of definitions, kindly provided by Greg + * Hitchcock. + * + * _Bi-Level_ _Rendering_ + * + * Monochromatic rendering, exclusively used in the early days of + * TrueType by both Apple and Microsoft. Microsoft's GDI interface + * supported hinting of the right-side bearing point, such that the + * advance width could be non-linear. Most often this was done to + * achieve some level of glyph symmetry. To enable reasonable + * performance (e.g., not having to run hinting on all glyphs just to + * get the widths) there was a bit in the head table indicating if the + * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to + * cache hinting widths across multiple sizes and device aspect ratios. + * + * _Font_ _Smoothing_ + * + * Microsoft's GDI implementation of anti-aliasing. Not traditional + * anti-aliasing as the outlines were hinted before the sampling. The + * widths matched the bi-level rendering. + * + * _ClearType_ _Rendering_ + * + * Technique that uses physical subpixels to improve rendering on LCD + * (and other) displays. Because of the higher resolution, many methods + * of improving symmetry in glyphs through hinting the right-side + * bearing were no longer necessary. This lead to what GDI calls + * `natural widths' ClearType, see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting + * has extra resolution, most non-linearity went away, but it is still + * possible for hints to change the advance widths in this mode. + * + * _ClearType_ _Compatible_ _Widths_ + * + * One of the earliest challenges with ClearType was allowing the + * implementation in GDI to be selected without requiring all UI and + * documents to reflow. To address this, a compatible method of + * rendering ClearType was added where the font hints are executed once + * to determine the width in bi-level rendering, and then re-run in + * ClearType, with the difference in widths being absorbed in the font + * hints for ClearType (mostly in the white space of hints); see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by + * definition, compatible width ClearType allows for non-linear widths, + * but only when the bi-level version has non-linear widths. + * + * _ClearType_ _Subpixel_ _Positioning_ + * + * One of the nice benefits of ClearType is the ability to more crisply + * display fractional widths; unfortunately, the GDI model of integer + * bitmaps did not support this. However, the WPF and Direct Write + * frameworks do support fractional widths. DWrite calls this `natural + * mode', not to be confused with GDI's `natural widths'. Subpixel + * positioning, in the current implementation of Direct Write, + * unfortunately does not support hinted advance widths, see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the + * TrueType interpreter fully allows the advance width to be adjusted in + * this mode, just the DWrite client will ignore those changes. + * + * _ClearType_ _Backwards_ _Compatibility_ + * + * This is a set of exceptions made in the TrueType interpreter to + * minimize hinting techniques that were problematic with the extra + * resolution of ClearType; see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and + * http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. + * This technique is not to be confused with ClearType compatible + * widths. ClearType backwards compatibility has no direct impact on + * changing advance widths, but there might be an indirect impact on + * disabling some deltas. This could be worked around in backwards + * compatibility mode. + * + * _Native_ _ClearType_ _Mode_ + * + * (Not to be confused with `natural widths'.) This mode removes all + * the exceptions in the TrueType interpreter when running with + * ClearType. Any issues on widths would still apply, though. + * + */ + + + /************************************************************************** + * + * @property: + * interpreter-version + * + * @description: + * Currently, two versions are available, representing the bytecode + * interpreter with and without subpixel hinting support, + * respectively. The default is subpixel support if + * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel + * support otherwise (since it isn't available then). + * + * If subpixel hinting is on, many TrueType bytecode instructions behave + * differently compared to B/W or grayscale rendering (except if `native + * ClearType' is selected by the font). The main idea is to render at a + * much increased horizontal resolution, then sampling down the created + * output to subpixel precision. However, many older fonts are not + * suited to this and must be specially taken care of by applying + * (hardcoded) font-specific tweaks. + * + * Details on subpixel hinting and some of the necessary tweaks can be + * found in Greg Hitchcock's whitepaper at + * `http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. + * + * The following example code demonstrates how to activate subpixel + * hinting (omitting the error handling). + * + * { + * FT_Library library; + * FT_Face face; + * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "truetype", + * "interpreter-version", + * &interpreter_version ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + */ + + + /************************************************************************** + * + * @enum: + * TT_INTERPRETER_VERSION_XXX + * + * @description: + * A list of constants used for the @interpreter-version property to + * select the hinting engine for Truetype fonts. + * + * The numeric value in the constant names represents the version + * number as returned by the `GETINFO' bytecode instruction. + * + * @values: + * TT_INTERPRETER_VERSION_35 :: + * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in + * Windows~98; only grayscale and B/W rasterizing is supported. + * + * TT_INTERPRETER_VERSION_38 :: + * Version~38 corresponds to MS rasterizer v.1.9; it is roughly + * equivalent to the hinting provided by DirectWrite ClearType (as + * can be found, for example, in the Internet Explorer~9 running on + * Windows~7). + * + * @note: + * This property controls the behaviour of the bytecode interpreter + * and thus how outlines get hinted. It does *not* control how glyph + * get rasterized! In particular, it does not control subpixel color + * filtering. + * + * If FreeType has not been compiled with configuration option + * FT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 causes an + * `FT_Err_Unimplemented_Feature' error. + * + * Depending on the graphics framework, Microsoft uses different + * bytecode and rendering engines. As a consequence, the version + * numbers returned by a call to the `GETINFO' bytecode instruction are + * more convoluted than desired. + * + * Here are two tables that try to shed some light on the possible + * values for the MS rasterizer engine, together with the additional + * features introduced by it. + * + * { + * GETINFO framework version feature + * ------------------------------------------------------------------- + * 3 GDI (Win 3.1), v1.0 16-bit, first version + * TrueImage + * 33 GDI (Win NT 3.1), v1.5 32-bit + * HP Laserjet + * 34 GDI (Win 95) v1.6 font smoothing, + * new SCANTYPE opcode + * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET + * bits in composite glyphs + * 36 MGDI (Win CE 2) v1.6+ classic ClearType + * 37 GDI (XP and later), v1.8 ClearType + * GDI+ old (before Vista) + * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType, + * WPF Y-direction ClearType, + * additional error checking + * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags + * in GETINFO opcode, + * bug fixes + * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag + * DWrite (Win 8) in GETINFO opcode, + * Gray ClearType + * } + * + * The `version' field gives a rough orientation only, since some + * applications provided certain features much earlier (as an example, + * Microsoft Reader used subpixel and Y-direction ClearType already in + * Windows 2000). Similarly, updates to a given framework might include + * improved hinting support. + * + * { + * version sampling rendering comment + * x y x y + * -------------------------------------------------------------- + * v1.0 normal normal B/W B/W bi-level + * v1.6 high high gray gray grayscale + * v1.8 high normal color-filter B/W (GDI) ClearType + * v1.9 high high color-filter gray Color ClearType + * v2.1 high normal gray B/W Gray ClearType + * v2.1 high high gray gray Gray ClearType + * } + * + * Color and Gray ClearType are the two available variants of + * `Y-direction ClearType', meaning grayscale rasterization along the + * Y-direction; the name used in the TrueType specification for this + * feature is `symmetric smoothing'. `Classic ClearType' is the + * original algorithm used before introducing a modified version in + * Win~XP. Another name for v1.6's grayscale rendering is `font + * smoothing', and `Color ClearType' is sometimes also called `DWrite + * ClearType'. To differentiate between today's Color ClearType and the + * earlier ClearType variant with B/W rendering along the vertical axis, + * the latter is sometimes called `GDI ClearType'. + * + * `Normal' and `high' sampling describe the (virtual) resolution to + * access the rasterized outline after the hinting process. `Normal' + * means 1 sample per grid line (i.e., B/W). In the current Microsoft + * implementation, `high' means an extra virtual resolution of 16x16 (or + * 16x1) grid lines per pixel for bytecode instructions like `MIRP'. + * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid + * lines for color filtering if Color ClearType is activated. + * + * Note that `Gray ClearType' is essentially the same as v1.6's + * grayscale rendering. However, the GETINFO instruction handles it + * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1 + * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing), + * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for + * the version~1 gasp table exclusively (like Color ClearType), while + * v1.6 only respects the values of version~0 (bits 0 and~1). + * + * FreeType doesn't provide all capabilities of the most recent + * ClearType incarnation, thus we identify our subpixel support as + * version~38. + * + */ +#define TT_INTERPRETER_VERSION_35 35 +#define TT_INTERPRETER_VERSION_38 38 + + /* */ + + +FT_END_HEADER + + +#endif /* FTTTDRV_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/fttypes.h b/foreign/freetype2/freetype/fttypes.h new file mode 100644 index 0000000..2673e79 --- /dev/null +++ b/foreign/freetype2/freetype/fttypes.h @@ -0,0 +1,602 @@ +/***************************************************************************/ +/* */ +/* fttypes.h */ +/* */ +/* FreeType simple types definitions (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTTYPES_H_ +#define FTTYPES_H_ + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_SYSTEM_H +#include FT_IMAGE_H + +#include <stddef.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /* <Title> */ + /* Basic Data Types */ + /* */ + /* <Abstract> */ + /* The basic data types defined by the library. */ + /* */ + /* <Description> */ + /* This section contains the basic data types defined by FreeType~2, */ + /* ranging from simple scalar types to bitmap descriptors. More */ + /* font-specific structures are defined in a different section. */ + /* */ + /* <Order> */ + /* FT_Byte */ + /* FT_Bytes */ + /* FT_Char */ + /* FT_Int */ + /* FT_UInt */ + /* FT_Int16 */ + /* FT_UInt16 */ + /* FT_Int32 */ + /* FT_UInt32 */ + /* FT_Int64 */ + /* FT_UInt64 */ + /* FT_Short */ + /* FT_UShort */ + /* FT_Long */ + /* FT_ULong */ + /* FT_Bool */ + /* FT_Offset */ + /* FT_PtrDist */ + /* FT_String */ + /* FT_Tag */ + /* FT_Error */ + /* FT_Fixed */ + /* FT_Pointer */ + /* FT_Pos */ + /* FT_Vector */ + /* FT_BBox */ + /* FT_Matrix */ + /* FT_FWord */ + /* FT_UFWord */ + /* FT_F2Dot14 */ + /* FT_UnitVector */ + /* FT_F26Dot6 */ + /* FT_Data */ + /* */ + /* FT_MAKE_TAG */ + /* */ + /* FT_Generic */ + /* FT_Generic_Finalizer */ + /* */ + /* FT_Bitmap */ + /* FT_Pixel_Mode */ + /* FT_Palette_Mode */ + /* FT_Glyph_Format */ + /* FT_IMAGE_TAG */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Bool */ + /* */ + /* <Description> */ + /* A typedef of unsigned char, used for simple booleans. As usual, */ + /* values 1 and~0 represent true and false, respectively. */ + /* */ + typedef unsigned char FT_Bool; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_FWord */ + /* */ + /* <Description> */ + /* A signed 16-bit integer used to store a distance in original font */ + /* units. */ + /* */ + typedef signed short FT_FWord; /* distance in FUnits */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UFWord */ + /* */ + /* <Description> */ + /* An unsigned 16-bit integer used to store a distance in original */ + /* font units. */ + /* */ + typedef unsigned short FT_UFWord; /* unsigned distance */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Char */ + /* */ + /* <Description> */ + /* A simple typedef for the _signed_ char type. */ + /* */ + typedef signed char FT_Char; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Byte */ + /* */ + /* <Description> */ + /* A simple typedef for the _unsigned_ char type. */ + /* */ + typedef unsigned char FT_Byte; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Bytes */ + /* */ + /* <Description> */ + /* A typedef for constant memory areas. */ + /* */ + typedef const FT_Byte* FT_Bytes; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Tag */ + /* */ + /* <Description> */ + /* A typedef for 32-bit tags (as used in the SFNT format). */ + /* */ + typedef FT_UInt32 FT_Tag; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_String */ + /* */ + /* <Description> */ + /* A simple typedef for the char type, usually used for strings. */ + /* */ + typedef char FT_String; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Short */ + /* */ + /* <Description> */ + /* A typedef for signed short. */ + /* */ + typedef signed short FT_Short; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UShort */ + /* */ + /* <Description> */ + /* A typedef for unsigned short. */ + /* */ + typedef unsigned short FT_UShort; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Int */ + /* */ + /* <Description> */ + /* A typedef for the int type. */ + /* */ + typedef signed int FT_Int; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UInt */ + /* */ + /* <Description> */ + /* A typedef for the unsigned int type. */ + /* */ + typedef unsigned int FT_UInt; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Long */ + /* */ + /* <Description> */ + /* A typedef for signed long. */ + /* */ + typedef signed long FT_Long; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ULong */ + /* */ + /* <Description> */ + /* A typedef for unsigned long. */ + /* */ + typedef unsigned long FT_ULong; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F2Dot14 */ + /* */ + /* <Description> */ + /* A signed 2.14 fixed-point type used for unit vectors. */ + /* */ + typedef signed short FT_F2Dot14; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F26Dot6 */ + /* */ + /* <Description> */ + /* A signed 26.6 fixed-point type used for vectorial pixel */ + /* coordinates. */ + /* */ + typedef signed long FT_F26Dot6; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Fixed */ + /* */ + /* <Description> */ + /* This type is used to store 16.16 fixed-point values, like scaling */ + /* values or matrix coefficients. */ + /* */ + typedef signed long FT_Fixed; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Error */ + /* */ + /* <Description> */ + /* The FreeType error code type. A value of~0 is always interpreted */ + /* as a successful operation. */ + /* */ + typedef int FT_Error; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Pointer */ + /* */ + /* <Description> */ + /* A simple typedef for a typeless pointer. */ + /* */ + typedef void* FT_Pointer; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Offset */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ + /* _unsigned_ integer type used to express a file size or position, */ + /* or a memory block size. */ + /* */ + typedef size_t FT_Offset; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_PtrDist */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ + /* largest _signed_ integer type used to express the distance */ + /* between two pointers. */ + /* */ + typedef ft_ptrdiff_t FT_PtrDist; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_UnitVector */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2D vector unit vector. Uses */ + /* FT_F2Dot14 types. */ + /* */ + /* <Fields> */ + /* x :: Horizontal coordinate. */ + /* */ + /* y :: Vertical coordinate. */ + /* */ + typedef struct FT_UnitVector_ + { + FT_F2Dot14 x; + FT_F2Dot14 y; + + } FT_UnitVector; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Matrix */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2x2 matrix. Coefficients are */ + /* in 16.16 fixed-point format. The computation performed is: */ + /* */ + /* { */ + /* x' = x*xx + y*xy */ + /* y' = x*yx + y*yy */ + /* } */ + /* */ + /* <Fields> */ + /* xx :: Matrix coefficient. */ + /* */ + /* xy :: Matrix coefficient. */ + /* */ + /* yx :: Matrix coefficient. */ + /* */ + /* yy :: Matrix coefficient. */ + /* */ + typedef struct FT_Matrix_ + { + FT_Fixed xx, xy; + FT_Fixed yx, yy; + + } FT_Matrix; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Data */ + /* */ + /* <Description> */ + /* Read-only binary data represented as a pointer and a length. */ + /* */ + /* <Fields> */ + /* pointer :: The data. */ + /* */ + /* length :: The length of the data in bytes. */ + /* */ + typedef struct FT_Data_ + { + const FT_Byte* pointer; + FT_Int length; + + } FT_Data; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Generic_Finalizer */ + /* */ + /* <Description> */ + /* Describe a function used to destroy the `client' data of any */ + /* FreeType object. See the description of the @FT_Generic type for */ + /* details of usage. */ + /* */ + /* <Input> */ + /* The address of the FreeType object that is under finalization. */ + /* Its client data is accessed through its `generic' field. */ + /* */ + typedef void (*FT_Generic_Finalizer)(void* object); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Generic */ + /* */ + /* <Description> */ + /* Client applications often need to associate their own data to a */ + /* variety of FreeType core objects. For example, a text layout API */ + /* might want to associate a glyph cache to a given size object. */ + /* */ + /* Some FreeType object contains a `generic' field, of type */ + /* FT_Generic, which usage is left to client applications and font */ + /* servers. */ + /* */ + /* It can be used to store a pointer to client-specific data, as well */ + /* as the address of a `finalizer' function, which will be called by */ + /* FreeType when the object is destroyed (for example, the previous */ + /* client example would put the address of the glyph cache destructor */ + /* in the `finalizer' field). */ + /* */ + /* <Fields> */ + /* data :: A typeless pointer to any client-specified data. This */ + /* field is completely ignored by the FreeType library. */ + /* */ + /* finalizer :: A pointer to a `generic finalizer' function, which */ + /* will be called when the object is destroyed. If this */ + /* field is set to NULL, no code will be called. */ + /* */ + typedef struct FT_Generic_ + { + void* data; + FT_Generic_Finalizer finalizer; + + } FT_Generic; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_MAKE_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags that are used to label */ + /* TrueType tables into an unsigned long, to be used within FreeType. */ + /* */ + /* <Note> */ + /* The produced values *must* be 32-bit integers. Don't redefine */ + /* this macro. */ + /* */ +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ + (FT_Tag) \ + ( ( (FT_ULong)_x1 << 24 ) | \ + ( (FT_ULong)_x2 << 16 ) | \ + ( (FT_ULong)_x3 << 8 ) | \ + (FT_ULong)_x4 ) + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* L I S T M A N A G E M E N T */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* list_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ListNode */ + /* */ + /* <Description> */ + /* Many elements and objects in FreeType are listed through an */ + /* @FT_List record (see @FT_ListRec). As its name suggests, an */ + /* FT_ListNode is a handle to a single list element. */ + /* */ + typedef struct FT_ListNodeRec_* FT_ListNode; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_List */ + /* */ + /* <Description> */ + /* A handle to a list record (see @FT_ListRec). */ + /* */ + typedef struct FT_ListRec_* FT_List; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListNodeRec */ + /* */ + /* <Description> */ + /* A structure used to hold a single list element. */ + /* */ + /* <Fields> */ + /* prev :: The previous element in the list. NULL if first. */ + /* */ + /* next :: The next element in the list. NULL if last. */ + /* */ + /* data :: A typeless pointer to the listed object. */ + /* */ + typedef struct FT_ListNodeRec_ + { + FT_ListNode prev; + FT_ListNode next; + void* data; + + } FT_ListNodeRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListRec */ + /* */ + /* <Description> */ + /* A structure used to hold a simple doubly-linked list. These are */ + /* used in many parts of FreeType. */ + /* */ + /* <Fields> */ + /* head :: The head (first element) of doubly-linked list. */ + /* */ + /* tail :: The tail (last element) of doubly-linked list. */ + /* */ + typedef struct FT_ListRec_ + { + FT_ListNode head; + FT_ListNode tail; + + } FT_ListRec; + + /* */ + + +#define FT_IS_EMPTY( list ) ( (list).head == 0 ) +#define FT_BOOL( x ) ( (FT_Bool)( x ) ) + + /* concatenate C tokens */ +#define FT_ERR_XCAT( x, y ) x ## y +#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) + + /* see `ftmoderr.h' for descriptions of the following macros */ + +#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) + +#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) +#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) + +#define FT_ERR_EQ( x, e ) \ + ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) +#define FT_ERR_NEQ( x, e ) \ + ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) + + +FT_END_HEADER + +#endif /* FTTYPES_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ftwinfnt.h b/foreign/freetype2/freetype/ftwinfnt.h new file mode 100644 index 0000000..a1a715b --- /dev/null +++ b/foreign/freetype2/freetype/ftwinfnt.h @@ -0,0 +1,275 @@ +/***************************************************************************/ +/* */ +/* ftwinfnt.h */ +/* */ +/* FreeType API for accessing Windows fnt-specific data. */ +/* */ +/* Copyright 2003-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTWINFNT_H_ +#define FTWINFNT_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* winfnt_fonts */ + /* */ + /* <Title> */ + /* Window FNT Files */ + /* */ + /* <Abstract> */ + /* Windows FNT specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Windows FNT specific */ + /* functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @enum: + * FT_WinFNT_ID_XXX + * + * @description: + * A list of valid values for the `charset' byte in + * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX + * encodings (except for cp1361) can be found at + * ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS + * subdirectory. cp1361 is roughly a superset of + * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT. + * + * @values: + * FT_WinFNT_ID_DEFAULT :: + * This is used for font enumeration and font creation as a + * `don't care' value. Valid font files don't contain this value. + * When querying for information about the character set of the font + * that is currently selected into a specified device context, this + * return value (of the related Windows API) simply denotes failure. + * + * FT_WinFNT_ID_SYMBOL :: + * There is no known mapping table available. + * + * FT_WinFNT_ID_MAC :: + * Mac Roman encoding. + * + * FT_WinFNT_ID_OEM :: + * From Michael Pöttgen <michael@poettgen.de>: + * + * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM + * is used for the charset of vector fonts, like `modern.fon', + * `roman.fon', and `script.fon' on Windows. + * + * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value + * specifies a character set that is operating-system dependent. + * + * The `IFIMETRICS' documentation from the `Windows Driver + * Development Kit' says: This font supports an OEM-specific + * character set. The OEM character set is system dependent. + * + * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the + * second default codepage that most international versions of + * Windows have. It is one of the OEM codepages from + * + * https://msdn.microsoft.com/en-us/goglobal/bb964655, + * + * and is used for the `DOS boxes', to support legacy applications. + * A German Windows version for example usually uses ANSI codepage + * 1252 and OEM codepage 850. + * + * FT_WinFNT_ID_CP874 :: + * A superset of Thai TIS 620 and ISO 8859-11. + * + * FT_WinFNT_ID_CP932 :: + * A superset of Japanese Shift-JIS (with minor deviations). + * + * FT_WinFNT_ID_CP936 :: + * A superset of simplified Chinese GB 2312-1980 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP949 :: + * A superset of Korean Hangul KS~C 5601-1987 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP950 :: + * A superset of traditional Chinese Big~5 ETen (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP1250 :: + * A superset of East European ISO 8859-2 (with slightly different + * ordering). + * + * FT_WinFNT_ID_CP1251 :: + * A superset of Russian ISO 8859-5 (with different ordering). + * + * FT_WinFNT_ID_CP1252 :: + * ANSI encoding. A superset of ISO 8859-1. + * + * FT_WinFNT_ID_CP1253 :: + * A superset of Greek ISO 8859-7 (with minor modifications). + * + * FT_WinFNT_ID_CP1254 :: + * A superset of Turkish ISO 8859-9. + * + * FT_WinFNT_ID_CP1255 :: + * A superset of Hebrew ISO 8859-8 (with some modifications). + * + * FT_WinFNT_ID_CP1256 :: + * A superset of Arabic ISO 8859-6 (with different ordering). + * + * FT_WinFNT_ID_CP1257 :: + * A superset of Baltic ISO 8859-13 (with some deviations). + * + * FT_WinFNT_ID_CP1258 :: + * For Vietnamese. This encoding doesn't cover all necessary + * characters. + * + * FT_WinFNT_ID_CP1361 :: + * Korean (Johab). + */ + +#define FT_WinFNT_ID_CP1252 0 +#define FT_WinFNT_ID_DEFAULT 1 +#define FT_WinFNT_ID_SYMBOL 2 +#define FT_WinFNT_ID_MAC 77 +#define FT_WinFNT_ID_CP932 128 +#define FT_WinFNT_ID_CP949 129 +#define FT_WinFNT_ID_CP1361 130 +#define FT_WinFNT_ID_CP936 134 +#define FT_WinFNT_ID_CP950 136 +#define FT_WinFNT_ID_CP1253 161 +#define FT_WinFNT_ID_CP1254 162 +#define FT_WinFNT_ID_CP1258 163 +#define FT_WinFNT_ID_CP1255 177 +#define FT_WinFNT_ID_CP1256 178 +#define FT_WinFNT_ID_CP1257 186 +#define FT_WinFNT_ID_CP1251 204 +#define FT_WinFNT_ID_CP874 222 +#define FT_WinFNT_ID_CP1250 238 +#define FT_WinFNT_ID_OEM 255 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_WinFNT_HeaderRec */ + /* */ + /* <Description> */ + /* Windows FNT Header info. */ + /* */ + typedef struct FT_WinFNT_HeaderRec_ + { + FT_UShort version; + FT_ULong file_size; + FT_Byte copyright[60]; + FT_UShort file_type; + FT_UShort nominal_point_size; + FT_UShort vertical_resolution; + FT_UShort horizontal_resolution; + FT_UShort ascent; + FT_UShort internal_leading; + FT_UShort external_leading; + FT_Byte italic; + FT_Byte underline; + FT_Byte strike_out; + FT_UShort weight; + FT_Byte charset; + FT_UShort pixel_width; + FT_UShort pixel_height; + FT_Byte pitch_and_family; + FT_UShort avg_width; + FT_UShort max_width; + FT_Byte first_char; + FT_Byte last_char; + FT_Byte default_char; + FT_Byte break_char; + FT_UShort bytes_per_row; + FT_ULong device_offset; + FT_ULong face_name_offset; + FT_ULong bits_pointer; + FT_ULong bits_offset; + FT_Byte reserved; + FT_ULong flags; + FT_UShort A_space; + FT_UShort B_space; + FT_UShort C_space; + FT_UShort color_table_offset; + FT_ULong reserved1[4]; + + } FT_WinFNT_HeaderRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_WinFNT_Header */ + /* */ + /* <Description> */ + /* A handle to an @FT_WinFNT_HeaderRec structure. */ + /* */ + typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; + + + /********************************************************************** + * + * @function: + * FT_Get_WinFNT_Header + * + * @description: + * Retrieve a Windows FNT font info header. + * + * @input: + * face :: A handle to the input face. + * + * @output: + * aheader :: The WinFNT header. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with Windows FNT faces, returning an error + * otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_WinFNT_Header( FT_Face face, + FT_WinFNT_HeaderRec *aheader ); + + /* */ + + +FT_END_HEADER + +#endif /* FTWINFNT_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/foreign/freetype2/freetype/t1tables.h b/foreign/freetype2/freetype/t1tables.h new file mode 100644 index 0000000..e272324 --- /dev/null +++ b/foreign/freetype2/freetype/t1tables.h @@ -0,0 +1,761 @@ +/***************************************************************************/ +/* */ +/* t1tables.h */ +/* */ +/* Basic Type 1/Type 2 tables definitions and interface (specification */ +/* only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef T1TABLES_H_ +#define T1TABLES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* type1_tables */ + /* */ + /* <Title> */ + /* Type 1 Tables */ + /* */ + /* <Abstract> */ + /* Type~1 (PostScript) specific font tables. */ + /* */ + /* <Description> */ + /* This section contains the definition of Type 1-specific tables, */ + /* including structures related to other PostScript font formats. */ + /* */ + /* <Order> */ + /* PS_FontInfoRec */ + /* PS_FontInfo */ + /* PS_PrivateRec */ + /* PS_Private */ + /* */ + /* CID_FaceDictRec */ + /* CID_FaceDict */ + /* CID_FaceInfoRec */ + /* CID_FaceInfo */ + /* */ + /* FT_Has_PS_Glyph_Names */ + /* FT_Get_PS_Font_Info */ + /* FT_Get_PS_Font_Private */ + /* FT_Get_PS_Font_Value */ + /* */ + /* T1_Blend_Flags */ + /* T1_EncodingType */ + /* PS_Dict_Keys */ + /* */ + /*************************************************************************/ + + + /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ + /* structures in order to support Multiple Master fonts. */ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_FontInfoRec */ + /* */ + /* <Description> */ + /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ + /* Note that for Multiple Master fonts, each instance has its own */ + /* FontInfo dictionary. */ + /* */ + typedef struct PS_FontInfoRec_ + { + FT_String* version; + FT_String* notice; + FT_String* full_name; + FT_String* family_name; + FT_String* weight; + FT_Long italic_angle; + FT_Bool is_fixed_pitch; + FT_Short underline_position; + FT_UShort underline_thickness; + + } PS_FontInfoRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_FontInfo */ + /* */ + /* <Description> */ + /* A handle to a @PS_FontInfoRec structure. */ + /* */ + typedef struct PS_FontInfoRec_* PS_FontInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* T1_FontInfo */ + /* */ + /* <Description> */ + /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef PS_FontInfoRec T1_FontInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_PrivateRec */ + /* */ + /* <Description> */ + /* A structure used to model a Type~1 or Type~2 private dictionary. */ + /* Note that for Multiple Master fonts, each instance has its own */ + /* Private dictionary. */ + /* */ + typedef struct PS_PrivateRec_ + { + FT_Int unique_id; + FT_Int lenIV; + + FT_Byte num_blue_values; + FT_Byte num_other_blues; + FT_Byte num_family_blues; + FT_Byte num_family_other_blues; + + FT_Short blue_values[14]; + FT_Short other_blues[10]; + + FT_Short family_blues [14]; + FT_Short family_other_blues[10]; + + FT_Fixed blue_scale; + FT_Int blue_shift; + FT_Int blue_fuzz; + + FT_UShort standard_width[1]; + FT_UShort standard_height[1]; + + FT_Byte num_snap_widths; + FT_Byte num_snap_heights; + FT_Bool force_bold; + FT_Bool round_stem_up; + + FT_Short snap_widths [13]; /* including std width */ + FT_Short snap_heights[13]; /* including std height */ + + FT_Fixed expansion_factor; + + FT_Long language_group; + FT_Long password; + + FT_Short min_feature[2]; + + } PS_PrivateRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_Private */ + /* */ + /* <Description> */ + /* A handle to a @PS_PrivateRec structure. */ + /* */ + typedef struct PS_PrivateRec_* PS_Private; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* T1_Private */ + /* */ + /* <Description> */ + /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef PS_PrivateRec T1_Private; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* T1_Blend_Flags */ + /* */ + /* <Description> */ + /* A set of flags used to indicate which fields are present in a */ + /* given blend dictionary (font info or private). Used to support */ + /* Multiple Masters fonts. */ + /* */ + /* <Values> */ + /* T1_BLEND_UNDERLINE_POSITION :: */ + /* T1_BLEND_UNDERLINE_THICKNESS :: */ + /* T1_BLEND_ITALIC_ANGLE :: */ + /* T1_BLEND_BLUE_VALUES :: */ + /* T1_BLEND_OTHER_BLUES :: */ + /* T1_BLEND_STANDARD_WIDTH :: */ + /* T1_BLEND_STANDARD_HEIGHT :: */ + /* T1_BLEND_STEM_SNAP_WIDTHS :: */ + /* T1_BLEND_STEM_SNAP_HEIGHTS :: */ + /* T1_BLEND_BLUE_SCALE :: */ + /* T1_BLEND_BLUE_SHIFT :: */ + /* T1_BLEND_FAMILY_BLUES :: */ + /* T1_BLEND_FAMILY_OTHER_BLUES :: */ + /* T1_BLEND_FORCE_BOLD :: */ + /* */ + typedef enum T1_Blend_Flags_ + { + /* required fields in a FontInfo blend dictionary */ + T1_BLEND_UNDERLINE_POSITION = 0, + T1_BLEND_UNDERLINE_THICKNESS, + T1_BLEND_ITALIC_ANGLE, + + /* required fields in a Private blend dictionary */ + T1_BLEND_BLUE_VALUES, + T1_BLEND_OTHER_BLUES, + T1_BLEND_STANDARD_WIDTH, + T1_BLEND_STANDARD_HEIGHT, + T1_BLEND_STEM_SNAP_WIDTHS, + T1_BLEND_STEM_SNAP_HEIGHTS, + T1_BLEND_BLUE_SCALE, + T1_BLEND_BLUE_SHIFT, + T1_BLEND_FAMILY_BLUES, + T1_BLEND_FAMILY_OTHER_BLUES, + T1_BLEND_FORCE_BOLD, + + T1_BLEND_MAX /* do not remove */ + + } T1_Blend_Flags; + + + /* these constants are deprecated; use the corresponding */ + /* `T1_Blend_Flags' values instead */ +#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION +#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS +#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE +#define t1_blend_blue_values T1_BLEND_BLUE_VALUES +#define t1_blend_other_blues T1_BLEND_OTHER_BLUES +#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH +#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT +#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS +#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS +#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE +#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT +#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES +#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES +#define t1_blend_force_bold T1_BLEND_FORCE_BOLD +#define t1_blend_max T1_BLEND_MAX + + /* */ + + + /* maximum number of Multiple Masters designs, as defined in the spec */ +#define T1_MAX_MM_DESIGNS 16 + + /* maximum number of Multiple Masters axes, as defined in the spec */ +#define T1_MAX_MM_AXIS 4 + + /* maximum number of elements in a design map */ +#define T1_MAX_MM_MAP_POINTS 20 + + + /* this structure is used to store the BlendDesignMap entry for an axis */ + typedef struct PS_DesignMap_ + { + FT_Byte num_points; + FT_Long* design_points; + FT_Fixed* blend_points; + + } PS_DesignMapRec, *PS_DesignMap; + + /* backwards-compatible definition */ + typedef PS_DesignMapRec T1_DesignMap; + + + typedef struct PS_BlendRec_ + { + FT_UInt num_designs; + FT_UInt num_axis; + + FT_String* axis_names[T1_MAX_MM_AXIS]; + FT_Fixed* design_pos[T1_MAX_MM_DESIGNS]; + PS_DesignMapRec design_map[T1_MAX_MM_AXIS]; + + FT_Fixed* weight_vector; + FT_Fixed* default_weight_vector; + + PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1]; + PS_Private privates [T1_MAX_MM_DESIGNS + 1]; + + FT_ULong blend_bitflags; + + FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1]; + + /* since 2.3.0 */ + + /* undocumented, optional: the default design instance; */ + /* corresponds to default_weight_vector -- */ + /* num_default_design_vector == 0 means it is not present */ + /* in the font and associated metrics files */ + FT_UInt default_design_vector[T1_MAX_MM_DESIGNS]; + FT_UInt num_default_design_vector; + + } PS_BlendRec, *PS_Blend; + + + /* backwards-compatible definition */ + typedef PS_BlendRec T1_Blend; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceDictRec */ + /* */ + /* <Description> */ + /* A structure used to represent data in a CID top-level dictionary. */ + /* */ + typedef struct CID_FaceDictRec_ + { + PS_PrivateRec private_dict; + + FT_UInt len_buildchar; + FT_Fixed forcebold_threshold; + FT_Pos stroke_width; + FT_Fixed expansion_factor; + + FT_Byte paint_type; + FT_Byte font_type; + FT_Matrix font_matrix; + FT_Vector font_offset; + + FT_UInt num_subrs; + FT_ULong subrmap_offset; + FT_Int sd_bytes; + + } CID_FaceDictRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceDict */ + /* */ + /* <Description> */ + /* A handle to a @CID_FaceDictRec structure. */ + /* */ + typedef struct CID_FaceDictRec_* CID_FaceDict; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FontDict */ + /* */ + /* <Description> */ + /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef CID_FaceDictRec CID_FontDict; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceInfoRec */ + /* */ + /* <Description> */ + /* A structure used to represent CID Face information. */ + /* */ + typedef struct CID_FaceInfoRec_ + { + FT_String* cid_font_name; + FT_Fixed cid_version; + FT_Int cid_font_type; + + FT_String* registry; + FT_String* ordering; + FT_Int supplement; + + PS_FontInfoRec font_info; + FT_BBox font_bbox; + FT_ULong uid_base; + + FT_Int num_xuid; + FT_ULong xuid[16]; + + FT_ULong cidmap_offset; + FT_Int fd_bytes; + FT_Int gd_bytes; + FT_ULong cid_count; + + FT_Int num_dicts; + CID_FaceDict font_dicts; + + FT_ULong data_offset; + + } CID_FaceInfoRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceInfo */ + /* */ + /* <Description> */ + /* A handle to a @CID_FaceInfoRec structure. */ + /* */ + typedef struct CID_FaceInfoRec_* CID_FaceInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_Info */ + /* */ + /* <Description> */ + /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef CID_FaceInfoRec CID_Info; + + + /************************************************************************ + * + * @function: + * FT_Has_PS_Glyph_Names + * + * @description: + * Return true if a given face provides reliable PostScript glyph + * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, + * except that certain fonts (mostly TrueType) contain incorrect + * glyph name tables. + * + * When this function returns true, the caller is sure that the glyph + * names returned by @FT_Get_Glyph_Name are reliable. + * + * @input: + * face :: + * face handle + * + * @return: + * Boolean. True if glyph names are reliable. + * + */ + FT_EXPORT( FT_Int ) + FT_Has_PS_Glyph_Names( FT_Face face ); + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Info + * + * @description: + * Retrieve the @PS_FontInfoRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_info :: + * Output font info structure pointer. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * String pointers within the @PS_FontInfoRec structure are owned by + * the face and don't need to be freed by the caller. Missing entries + * in the font's FontInfo dictionary are represented by NULL pointers. + * + * If the font's format is not PostScript-based, this function will + * return the `FT_Err_Invalid_Argument' error code. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Info( FT_Face face, + PS_FontInfo afont_info ); + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Private + * + * @description: + * Retrieve the @PS_PrivateRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_private :: + * Output private dictionary structure pointer. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The string pointers within the @PS_PrivateRec structure are owned by + * the face and don't need to be freed by the caller. + * + * If the font's format is not PostScript-based, this function returns + * the `FT_Err_Invalid_Argument' error code. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Private( FT_Face face, + PS_Private afont_private ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* T1_EncodingType */ + /* */ + /* <Description> */ + /* An enumeration describing the `Encoding' entry in a Type 1 */ + /* dictionary. */ + /* */ + /* <Values> */ + /* T1_ENCODING_TYPE_NONE :: */ + /* T1_ENCODING_TYPE_ARRAY :: */ + /* T1_ENCODING_TYPE_STANDARD :: */ + /* T1_ENCODING_TYPE_ISOLATIN1 :: */ + /* T1_ENCODING_TYPE_EXPERT :: */ + /* */ + typedef enum T1_EncodingType_ + { + T1_ENCODING_TYPE_NONE = 0, + T1_ENCODING_TYPE_ARRAY, + T1_ENCODING_TYPE_STANDARD, + T1_ENCODING_TYPE_ISOLATIN1, + T1_ENCODING_TYPE_EXPERT + + } T1_EncodingType; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* PS_Dict_Keys */ + /* */ + /* <Description> */ + /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ + /* the Type~1 dictionary entry to retrieve. */ + /* */ + /* <Values> */ + /* PS_DICT_FONT_TYPE :: */ + /* PS_DICT_FONT_MATRIX :: */ + /* PS_DICT_FONT_BBOX :: */ + /* PS_DICT_PAINT_TYPE :: */ + /* PS_DICT_FONT_NAME :: */ + /* PS_DICT_UNIQUE_ID :: */ + /* PS_DICT_NUM_CHAR_STRINGS :: */ + /* PS_DICT_CHAR_STRING_KEY :: */ + /* PS_DICT_CHAR_STRING :: */ + /* PS_DICT_ENCODING_TYPE :: */ + /* PS_DICT_ENCODING_ENTRY :: */ + /* PS_DICT_NUM_SUBRS :: */ + /* PS_DICT_SUBR :: */ + /* PS_DICT_STD_HW :: */ + /* PS_DICT_STD_VW :: */ + /* PS_DICT_NUM_BLUE_VALUES :: */ + /* PS_DICT_BLUE_VALUE :: */ + /* PS_DICT_BLUE_FUZZ :: */ + /* PS_DICT_NUM_OTHER_BLUES :: */ + /* PS_DICT_OTHER_BLUE :: */ + /* PS_DICT_NUM_FAMILY_BLUES :: */ + /* PS_DICT_FAMILY_BLUE :: */ + /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */ + /* PS_DICT_FAMILY_OTHER_BLUE :: */ + /* PS_DICT_BLUE_SCALE :: */ + /* PS_DICT_BLUE_SHIFT :: */ + /* PS_DICT_NUM_STEM_SNAP_H :: */ + /* PS_DICT_STEM_SNAP_H :: */ + /* PS_DICT_NUM_STEM_SNAP_V :: */ + /* PS_DICT_STEM_SNAP_V :: */ + /* PS_DICT_FORCE_BOLD :: */ + /* PS_DICT_RND_STEM_UP :: */ + /* PS_DICT_MIN_FEATURE :: */ + /* PS_DICT_LEN_IV :: */ + /* PS_DICT_PASSWORD :: */ + /* PS_DICT_LANGUAGE_GROUP :: */ + /* PS_DICT_VERSION :: */ + /* PS_DICT_NOTICE :: */ + /* PS_DICT_FULL_NAME :: */ + /* PS_DICT_FAMILY_NAME :: */ + /* PS_DICT_WEIGHT :: */ + /* PS_DICT_IS_FIXED_PITCH :: */ + /* PS_DICT_UNDERLINE_POSITION :: */ + /* PS_DICT_UNDERLINE_THICKNESS :: */ + /* PS_DICT_FS_TYPE :: */ + /* PS_DICT_ITALIC_ANGLE :: */ + /* */ + typedef enum PS_Dict_Keys_ + { + /* conventionally in the font dictionary */ + PS_DICT_FONT_TYPE, /* FT_Byte */ + PS_DICT_FONT_MATRIX, /* FT_Fixed */ + PS_DICT_FONT_BBOX, /* FT_Fixed */ + PS_DICT_PAINT_TYPE, /* FT_Byte */ + PS_DICT_FONT_NAME, /* FT_String* */ + PS_DICT_UNIQUE_ID, /* FT_Int */ + PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */ + PS_DICT_CHAR_STRING_KEY, /* FT_String* */ + PS_DICT_CHAR_STRING, /* FT_String* */ + PS_DICT_ENCODING_TYPE, /* T1_EncodingType */ + PS_DICT_ENCODING_ENTRY, /* FT_String* */ + + /* conventionally in the font Private dictionary */ + PS_DICT_NUM_SUBRS, /* FT_Int */ + PS_DICT_SUBR, /* FT_String* */ + PS_DICT_STD_HW, /* FT_UShort */ + PS_DICT_STD_VW, /* FT_UShort */ + PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */ + PS_DICT_BLUE_VALUE, /* FT_Short */ + PS_DICT_BLUE_FUZZ, /* FT_Int */ + PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */ + PS_DICT_OTHER_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */ + PS_DICT_BLUE_SCALE, /* FT_Fixed */ + PS_DICT_BLUE_SHIFT, /* FT_Int */ + PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */ + PS_DICT_STEM_SNAP_H, /* FT_Short */ + PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */ + PS_DICT_STEM_SNAP_V, /* FT_Short */ + PS_DICT_FORCE_BOLD, /* FT_Bool */ + PS_DICT_RND_STEM_UP, /* FT_Bool */ + PS_DICT_MIN_FEATURE, /* FT_Short */ + PS_DICT_LEN_IV, /* FT_Int */ + PS_DICT_PASSWORD, /* FT_Long */ + PS_DICT_LANGUAGE_GROUP, /* FT_Long */ + + /* conventionally in the font FontInfo dictionary */ + PS_DICT_VERSION, /* FT_String* */ + PS_DICT_NOTICE, /* FT_String* */ + PS_DICT_FULL_NAME, /* FT_String* */ + PS_DICT_FAMILY_NAME, /* FT_String* */ + PS_DICT_WEIGHT, /* FT_String* */ + PS_DICT_IS_FIXED_PITCH, /* FT_Bool */ + PS_DICT_UNDERLINE_POSITION, /* FT_Short */ + PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ + PS_DICT_FS_TYPE, /* FT_UShort */ + PS_DICT_ITALIC_ANGLE, /* FT_Long */ + + PS_DICT_MAX = PS_DICT_ITALIC_ANGLE + + } PS_Dict_Keys; + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Value + * + * @description: + * Retrieve the value for the supplied key from a PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * key :: + * An enumeration value representing the dictionary key to retrieve. + * + * idx :: + * For array values, this specifies the index to be returned. + * + * value :: + * A pointer to memory into which to write the value. + * + * valen_len :: + * The size, in bytes, of the memory supplied for the value. + * + * @output: + * value :: + * The value matching the above key, if it exists. + * + * @return: + * The amount of memory (in bytes) required to hold the requested + * value (if it exists, -1 otherwise). + * + * @note: + * The values returned are not pointers into the internal structures of + * the face, but are `fresh' copies, so that the memory containing them + * belongs to the calling application. This also enforces the + * `read-only' nature of these values, i.e., this function cannot be + * used to manipulate the face. + * + * `value' is a void pointer because the values returned can be of + * various types. + * + * If either `value' is NULL or `value_len' is too small, just the + * required memory size for the requested entry is returned. + * + * The `idx' parameter is used, not only to retrieve elements of, for + * example, the FontMatrix or FontBBox, but also to retrieve name keys + * from the CharStrings dictionary, and the charstrings themselves. It + * is ignored for atomic values. + * + * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To + * get the value as in the font stream, you need to divide by + * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). + * + * IMPORTANT: Only key/value pairs read by the FreeType interpreter can + * be retrieved. So, for example, PostScript procedures such as NP, + * ND, and RD are not available. Arbitrary keys are, obviously, not be + * available either. + * + * If the font's format is not PostScript-based, this function returns + * the `FT_Err_Invalid_Argument' error code. + * + */ + FT_EXPORT( FT_Long ) + FT_Get_PS_Font_Value( FT_Face face, + PS_Dict_Keys key, + FT_UInt idx, + void *value, + FT_Long value_len ); + + /* */ + +FT_END_HEADER + +#endif /* T1TABLES_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ttnameid.h b/foreign/freetype2/freetype/ttnameid.h new file mode 100644 index 0000000..ce707f1 --- /dev/null +++ b/foreign/freetype2/freetype/ttnameid.h @@ -0,0 +1,1237 @@ +/***************************************************************************/ +/* */ +/* ttnameid.h */ +/* */ +/* TrueType name ID definitions (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTNAMEID_H_ +#define TTNAMEID_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* truetype_tables */ + /* */ + + + /*************************************************************************/ + /* */ + /* Possible values for the `platform' identifier code in the name */ + /* records of the TTF `name' table. */ + /* */ + /*************************************************************************/ + + + /*********************************************************************** + * + * @enum: + * TT_PLATFORM_XXX + * + * @description: + * A list of valid values for the `platform_id' identifier code in + * @FT_CharMapRec and @FT_SfntName structures. + * + * @values: + * TT_PLATFORM_APPLE_UNICODE :: + * Used by Apple to indicate a Unicode character map and/or name entry. + * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note + * that name entries in this format are coded as big-endian UCS-2 + * character codes _only_. + * + * TT_PLATFORM_MACINTOSH :: + * Used by Apple to indicate a MacOS-specific charmap and/or name entry. + * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that + * most TrueType fonts contain an Apple roman charmap to be usable on + * MacOS systems (even if they contain a Microsoft charmap as well). + * + * TT_PLATFORM_ISO :: + * This value was used to specify ISO/IEC 10646 charmaps. It is however + * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding + * `encoding_id' values. + * + * TT_PLATFORM_MICROSOFT :: + * Used by Microsoft to indicate Windows-specific charmaps. See + * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. + * Note that most fonts contain a Unicode charmap using + * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * + * TT_PLATFORM_CUSTOM :: + * Used to indicate application-specific charmaps. + * + * TT_PLATFORM_ADOBE :: + * This value isn't part of any font format specification, but is used + * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec + * structure. See @TT_ADOBE_ID_XXX. + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 /* deprecated */ +#define TT_PLATFORM_MICROSOFT 3 +#define TT_PLATFORM_CUSTOM 4 +#define TT_PLATFORM_ADOBE 7 /* artificial */ + + + /*********************************************************************** + * + * @enum: + * TT_APPLE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. + * + * @values: + * TT_APPLE_ID_DEFAULT :: + * Unicode version 1.0. + * + * TT_APPLE_ID_UNICODE_1_1 :: + * Unicode 1.1; specifies Hangul characters starting at U+34xx. + * + * TT_APPLE_ID_ISO_10646 :: + * Deprecated (identical to preceding). + * + * TT_APPLE_ID_UNICODE_2_0 :: + * Unicode 2.0 and beyond (UTF-16 BMP only). + * + * TT_APPLE_ID_UNICODE_32 :: + * Unicode 3.1 and beyond, using UTF-32. + * + * TT_APPLE_ID_VARIANT_SELECTOR :: + * From Adobe, not Apple. Not a normal cmap. Specifies variations + * on a real cmap. + */ + +#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ +#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ +#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ +#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ +#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ +#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ + + + /*********************************************************************** + * + * @enum: + * TT_MAC_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MACINTOSH charmaps and name entries. + * + * @values: + * TT_MAC_ID_ROMAN :: + * TT_MAC_ID_JAPANESE :: + * TT_MAC_ID_TRADITIONAL_CHINESE :: + * TT_MAC_ID_KOREAN :: + * TT_MAC_ID_ARABIC :: + * TT_MAC_ID_HEBREW :: + * TT_MAC_ID_GREEK :: + * TT_MAC_ID_RUSSIAN :: + * TT_MAC_ID_RSYMBOL :: + * TT_MAC_ID_DEVANAGARI :: + * TT_MAC_ID_GURMUKHI :: + * TT_MAC_ID_GUJARATI :: + * TT_MAC_ID_ORIYA :: + * TT_MAC_ID_BENGALI :: + * TT_MAC_ID_TAMIL :: + * TT_MAC_ID_TELUGU :: + * TT_MAC_ID_KANNADA :: + * TT_MAC_ID_MALAYALAM :: + * TT_MAC_ID_SINHALESE :: + * TT_MAC_ID_BURMESE :: + * TT_MAC_ID_KHMER :: + * TT_MAC_ID_THAI :: + * TT_MAC_ID_LAOTIAN :: + * TT_MAC_ID_GEORGIAN :: + * TT_MAC_ID_ARMENIAN :: + * TT_MAC_ID_MALDIVIAN :: + * TT_MAC_ID_SIMPLIFIED_CHINESE :: + * TT_MAC_ID_TIBETAN :: + * TT_MAC_ID_MONGOLIAN :: + * TT_MAC_ID_GEEZ :: + * TT_MAC_ID_SLAVIC :: + * TT_MAC_ID_VIETNAMESE :: + * TT_MAC_ID_SINDHI :: + * TT_MAC_ID_UNINTERP :: + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + + /*********************************************************************** + * + * @enum: + * TT_ISO_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ISO charmaps and name entries. + * + * Their use is now deprecated. + * + * @values: + * TT_ISO_ID_7BIT_ASCII :: + * ASCII. + * TT_ISO_ID_10646 :: + * ISO/10646. + * TT_ISO_ID_8859_1 :: + * Also known as Latin-1. + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + + /*********************************************************************** + * + * @enum: + * TT_MS_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MICROSOFT charmaps and name entries. + * + * @values: + * TT_MS_ID_SYMBOL_CS :: + * Corresponds to Microsoft symbol encoding. See + * @FT_ENCODING_MS_SYMBOL. + * + * TT_MS_ID_UNICODE_CS :: + * Corresponds to a Microsoft WGL4 charmap, matching Unicode. See + * @FT_ENCODING_UNICODE. + * + * TT_MS_ID_SJIS :: + * Corresponds to SJIS Japanese encoding. See @FT_ENCODING_SJIS. + * + * TT_MS_ID_GB2312 :: + * Corresponds to Simplified Chinese as used in Mainland China. See + * @FT_ENCODING_GB2312. + * + * TT_MS_ID_BIG_5 :: + * Corresponds to Traditional Chinese as used in Taiwan and Hong Kong. + * See @FT_ENCODING_BIG5. + * + * TT_MS_ID_WANSUNG :: + * Corresponds to Korean Wansung encoding. See @FT_ENCODING_WANSUNG. + * + * TT_MS_ID_JOHAB :: + * Corresponds to Johab encoding. See @FT_ENCODING_JOHAB. + * + * TT_MS_ID_UCS_4 :: + * Corresponds to UCS-4 or UTF-32 charmaps. This has been added to + * the OpenType specification version 1.4 (mid-2001.) + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_GB2312 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 +#define TT_MS_ID_UCS_4 10 + + + /*********************************************************************** + * + * @enum: + * TT_ADOBE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! + * + * @values: + * TT_ADOBE_ID_STANDARD :: + * Adobe standard encoding. + * TT_ADOBE_ID_EXPERT :: + * Adobe expert encoding. + * TT_ADOBE_ID_CUSTOM :: + * Adobe custom encoding. + * TT_ADOBE_ID_LATIN_1 :: + * Adobe Latin~1 encoding. + */ + +#define TT_ADOBE_ID_STANDARD 0 +#define TT_ADOBE_ID_EXPERT 1 +#define TT_ADOBE_ID_CUSTOM 2 +#define TT_ADOBE_ID_LATIN_1 3 + + + /*************************************************************************/ + /* */ + /* Possible values of the language identifier field in the name records */ + /* of the TTF `name' table if the `platform' identifier code is */ + /* TT_PLATFORM_MACINTOSH. These values are also used as return values */ + /* for function @FT_Get_CMap_Language_ID. */ + /* */ + /* The canonical source for the Apple assigned Language ID's is at */ + /* */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html */ + /* */ +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 + + +#if 0 /* these seem to be errors that have been dropped */ + +#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 +#define TT_MAC_LANGID_IRISH_GAELIC 141 + +#endif + + + /* The following codes are new as of 2000-03-10 */ +#define TT_MAC_LANGID_GALICIAN 140 +#define TT_MAC_LANGID_AFRIKAANS 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 +#define TT_MAC_LANGID_MANX_GAELIC 145 +#define TT_MAC_LANGID_IRISH_GAELIC 146 +#define TT_MAC_LANGID_TONGAN 147 +#define TT_MAC_LANGID_GREEK_POLYTONIC 148 +#define TT_MAC_LANGID_GREELANDIC 149 +#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 + + + /*************************************************************************/ + /* */ + /* Possible values of the language identifier field in the name records */ + /* of the TTF `name' table if the `platform' identifier code is */ + /* TT_PLATFORM_MICROSOFT. */ + /* */ + /* The canonical source for the MS assigned LCIDs is */ + /* */ + /* http://www.microsoft.com/globaldev/reference/lcid-all.mspx */ + /* */ + +#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 +#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 + +#if 1 /* this looks like the correct value */ +#define TT_MS_LANGID_CHINESE_MACAU 0x1404 +#else /* but beware, Microsoft may change its mind... + the most recent Word reference has the following: */ +#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG +#endif + +#if 0 /* used only with .NET `cultures'; commented out */ +#define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04 +#endif + +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 + + /* don't ask what this one means... It is commented out currently. */ +#if 0 +#define TT_MS_LANGID_GREEK_GREECE2 0x2008 +#endif + +#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 +#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09 +#define TT_MS_LANGID_ENGLISH_INDIA 0x4009 +#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409 +#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A +#define TT_MS_LANGID_SPANISH_MEXICO 0x080A +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0C0A +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A +#define TT_MS_LANGID_SPANISH_PANAMA 0x180A +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A +#define TT_MS_LANGID_SPANISH_PERU 0x280A +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A +#define TT_MS_LANGID_SPANISH_CHILE 0x340A +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A +#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A + /* The following ID blatantly violate MS specs by using a */ + /* sublanguage > 0x1F. */ +#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU +#define TT_MS_LANGID_FINNISH_FINLAND 0x040B +#define TT_MS_LANGID_FRENCH_FRANCE 0x040C +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C +#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C +#define TT_MS_LANGID_FRENCH_MONACO 0x180C +#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C +#define TT_MS_LANGID_FRENCH_REUNION 0x200C +#define TT_MS_LANGID_FRENCH_CONGO 0x240C + /* which was formerly: */ +#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO +#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C +#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C +#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C +#define TT_MS_LANGID_FRENCH_MALI 0x340C +#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C +#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C + /* and another violation of the spec (see 0xE40AU) */ +#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A + +#if 0 /* this used to be this value, but it looks like we were wrong */ +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x101A +#else /* current sources say */ +#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A + /* and XPsp2 Platform SDK added (2004-07-26) */ + /* Names are shortened to be significant within 40 chars. */ +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x181A +#endif + +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D +#define TT_MS_LANGID_THAI_THAILAND 0x041E +#define TT_MS_LANGID_TURKISH_TURKEY 0x041F +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_URDU_INDIA 0x0820 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428 +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C +#define TT_MS_LANGID_BASQUE_SPAIN 0x042D +#define TT_MS_LANGID_SORBIAN_GERMANY 0x042E +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043A + /* Added by XPsp2 Platform SDK (2004-07-26) */ +#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B +#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B +#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B +#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B +#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B +#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B +#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B +#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B +#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B + /* ... and we also keep our old identifier... */ +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B + +#if 0 /* this seems to be a previous inversion */ +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C +#else +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C +#endif + +#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E +#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043F +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN /* Cyrillic*/ 0x0440 + /* alias declared in Windows 2000 */ +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ + TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN + +#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ORIYA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044A +#define TT_MS_LANGID_KANNADA_INDIA 0x044B +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D +#define TT_MS_LANGID_MARATHI_INDIA 0x044E +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450 +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850 +#define TT_MS_LANGID_TIBETAN_CHINA 0x0451 + /* Don't use the next constant! It has */ + /* (1) the wrong spelling (Dzonghka) */ + /* (2) Microsoft doesn't officially define it -- */ + /* at least it is not in the List of Local */ + /* ID Values. */ + /* (3) Dzongkha is not the same language as */ + /* Tibetan, so merging it is wrong anyway. */ + /* */ + /* TT_MS_LANGID_TIBETAN_BHUTAN is correct, BTW. */ +#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 + +#if 0 + /* the following used to be defined */ +#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451 + /* ... but it was changed; */ +#else + /* So we will continue to #define it, but with the correct value */ +#define TT_MS_LANGID_TIBETAN_BHUTAN TT_MS_LANGID_DZONGHKA_BHUTAN +#endif + +#define TT_MS_LANGID_WELSH_WALES 0x0452 +#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 +#define TT_MS_LANGID_LAO_LAOS 0x0454 +#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 +#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456 +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 +#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 +#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 +#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 + /* Missing a LCID for Sindhi in Devanagari script */ +#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A +#define TT_MS_LANGID_SINHALESE_SRI_LANKA 0x045B +#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C +#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D +#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN 0x085F + /* Missing a LCID for Tifinagh script */ +#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 + /* Spelled this way by XPsp2 Platform SDK (2004-07-26) */ + /* script is yet unclear... might be Arabic, Nagari or Sharada */ +#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 + /* ... and aliased (by MS) for compatibility reasons. */ +#define TT_MS_LANGID_KASHMIRI_INDIA TT_MS_LANGID_KASHMIRI_SASIA +#define TT_MS_LANGID_NEPALI_NEPAL 0x0461 +#define TT_MS_LANGID_NEPALI_INDIA 0x0861 +#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 +#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 +#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 +#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 + /* alias declared in Windows 2000 */ +#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES +#define TT_MS_LANGID_EDO_NIGERIA 0x0466 +#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 +#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 +#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 +#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A +#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B +#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B +#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B +#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA 0x046C + /* Also spelled by XPsp2 Platform SDK (2004-07-26) */ +#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ + TT_MS_LANGID_SEPEDI_SOUTH_AFRICA + /* language codes 0x046D, 0x046E and 0x046F are (still) unknown. */ +#define TT_MS_LANGID_IGBO_NIGERIA 0x0470 +#define TT_MS_LANGID_KANURI_NIGERIA 0x0471 +#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 +#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 +#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 + /* also spelled in the `Passport SDK' list as: */ +#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA +#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 +#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 +#define TT_MS_LANGID_LATIN 0x0476 +#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 + /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */ + /* not written (but OTOH the peculiar writing system is worth */ + /* studying). */ +#define TT_MS_LANGID_YI_CHINA 0x0478 +#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 + /* language codes from 0x047A to 0x047F are (still) unknown. */ +#define TT_MS_LANGID_UIGHUR_CHINA 0x0480 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 + +#if 0 /* not deemed useful for fonts */ +#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE 0x04FF +#endif + + + /*************************************************************************/ + /* */ + /* Possible values of the `name' identifier field in the name records of */ + /* the TTF `name' table. These values are platform independent. */ + /* */ +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 + + /* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 + /* number 15 is reserved */ +#define TT_NAME_ID_PREFERRED_FAMILY 16 +#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + /* The following code is new as of 2000-01-21 */ +#define TT_NAME_ID_SAMPLE_TEXT 19 + + /* This is new in OpenType 1.3 */ +#define TT_NAME_ID_CID_FINDFONT_NAME 20 + + /* This is new in OpenType 1.5 */ +#define TT_NAME_ID_WWS_FAMILY 21 +#define TT_NAME_ID_WWS_SUBFAMILY 22 + + + /*************************************************************************/ + /* */ + /* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */ + /* */ + /* Updated 08-Nov-2008. */ + /* */ + + /* Bit 0 Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ + /* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ + /* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ + /* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ + /* Bit 4 IPA Extensions */ + /* Phonetic Extensions */ + /* Phonetic Extensions Supplement */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ + /* U+1D00-U+1D7F */ + /* U+1D80-U+1DBF */ + /* Bit 5 Spacing Modifier Letters */ + /* Modifier Tone Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ + /* U+A700-U+A71F */ + /* Bit 6 Combining Diacritical Marks */ + /* Combining Diacritical Marks Supplement */ +#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ + /* U+1DC0-U+1DFF */ + /* Bit 7 Greek and Coptic */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ + /* Bit 8 Coptic */ +#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */ + /* Bit 9 Cyrillic */ + /* Cyrillic Supplement */ + /* Cyrillic Extended-A */ + /* Cyrillic Extended-B */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ + /* U+0500-U+052F */ + /* U+2DE0-U+2DFF */ + /* U+A640-U+A69F */ + /* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ + /* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ + /* Bit 12 Vai */ +#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */ + /* Bit 13 Arabic */ + /* Arabic Supplement */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ + /* U+0750-U+077F */ + /* Bit 14 NKo */ +#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */ + /* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ + /* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ + /* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ + /* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ + /* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ + /* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ + /* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ + /* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ + /* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ + /* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ + /* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ + /* Bit 26 Georgian */ + /* Georgian Supplement */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ + /* U+2D00-U+2D2F */ + /* Bit 27 Balinese */ +#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */ + /* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ + /* Bit 29 Latin Extended Additional */ + /* Latin Extended-C */ + /* Latin Extended-D */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ + /* U+2C60-U+2C7F */ + /* U+A720-U+A7FF */ + /* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + /* Bit 31 General Punctuation */ + /* Supplemental Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ + /* U+2E00-U+2E7F */ + /* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ + /* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ + /* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ + /* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ + /* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ + /* Bit 37 Arrows */ + /* Supplemental Arrows-A */ + /* Supplemental Arrows-B */ + /* Miscellaneous Symbols and Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ + /* U+27F0-U+27FF */ + /* U+2900-U+297F */ + /* U+2B00-U+2BFF */ + /* Bit 38 Mathematical Operators */ + /* Supplemental Mathematical Operators */ + /* Miscellaneous Mathematical Symbols-A */ + /* Miscellaneous Mathematical Symbols-B */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ + /* U+2A00-U+2AFF */ + /* U+27C0-U+27EF */ + /* U+2980-U+29FF */ + /* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ + /* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ + /* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ + /* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ + /* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ + /* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ + /* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ + /* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ + /* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + /* Bit 48 CJK Symbols and Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ + /* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ + /* Bit 50 Katakana */ + /* Katakana Phonetic Extensions */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ + /* U+31F0-U+31FF */ + /* Bit 51 Bopomofo */ + /* Bopomofo Extended */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ + /* U+31A0-U+31BF */ + /* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ + /* Bit 53 Phags-Pa */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */ +#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */ +#define TT_UCR_PHAGSPA + /* Bit 54 Enclosed CJK Letters and Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ + /* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + /* Bit 56 Hangul Syllables */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + /* Bit 57 High Surrogates */ + /* High Private Use Surrogates */ + /* Low Surrogates */ + /* */ + /* According to OpenType specs v.1.3+, */ + /* setting bit 57 implies that there is */ + /* at least one codepoint beyond the */ + /* Basic Multilingual Plane that is */ + /* supported by this font. So it really */ + /* means >= U+10000 */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ + /* U+DB80-U+DBFF */ + /* U+DC00-U+DFFF */ +#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES + /* Bit 58 Phoenician */ +#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/ + /* Bit 59 CJK Unified Ideographs */ + /* CJK Radicals Supplement */ + /* Kangxi Radicals */ + /* Ideographic Description Characters */ + /* CJK Unified Ideographs Extension A */ + /* CJK Unified Ideographs Extension B */ + /* Kanbun */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + /* U+2E80-U+2EFF */ + /* U+2F00-U+2FDF */ + /* U+2FF0-U+2FFF */ + /* U+3400-U+4DB5 */ + /*U+20000-U+2A6DF*/ + /* U+3190-U+319F */ + /* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + /* Bit 61 CJK Strokes */ + /* CJK Compatibility Ideographs */ + /* CJK Compatibility Ideographs Supplement */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */ + /* U+F900-U+FAFF */ + /*U+2F800-U+2FA1F*/ + /* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ + /* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */ + /* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ + /* Bit 65 Vertical forms */ + /* CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */ + /* U+FE30-U+FE4F */ + /* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ + /* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */ + /* Bit 68 Halfwidth and Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ + /* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ + /* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */ + /* Bit 71 Syriac */ +#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ + /* Bit 72 Thaana */ +#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ + /* Bit 73 Sinhala */ +#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ + /* Bit 74 Myanmar */ +#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ + /* Bit 75 Ethiopic */ + /* Ethiopic Supplement */ + /* Ethiopic Extended */ +#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */ + /* U+1380-U+139F */ + /* U+2D80-U+2DDF */ + /* Bit 76 Cherokee */ +#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ + /* Bit 77 Unified Canadian Aboriginal Syllabics */ +#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */ + /* Bit 78 Ogham */ +#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ + /* Bit 79 Runic */ +#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ + /* Bit 80 Khmer */ + /* Khmer Symbols */ +#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ + /* U+19E0-U+19FF */ + /* Bit 81 Mongolian */ +#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ + /* Bit 82 Braille Patterns */ +#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ + /* Bit 83 Yi Syllables */ + /* Yi Radicals */ +#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */ + /* U+A490-U+A4CF */ + /* Bit 84 Tagalog */ + /* Hanunoo */ + /* Buhid */ + /* Tagbanwa */ +#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */ + /* U+1720-U+173F */ + /* U+1740-U+175F */ + /* U+1760-U+177F */ + /* Bit 85 Old Italic */ +#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/ + /* Bit 86 Gothic */ +#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/ + /* Bit 87 Deseret */ +#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/ + /* Bit 88 Byzantine Musical Symbols */ + /* Musical Symbols */ + /* Ancient Greek Musical Notation */ +#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/ + /*U+1D100-U+1D1FF*/ + /*U+1D200-U+1D24F*/ + /* Bit 89 Mathematical Alphanumeric Symbols */ +#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/ + /* Bit 90 Private Use (plane 15) */ + /* Private Use (plane 16) */ +#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/ + /*U+100000-U+10FFFD*/ + /* Bit 91 Variation Selectors */ + /* Variation Selectors Supplement */ +#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */ + /*U+E0100-U+E01EF*/ + /* Bit 92 Tags */ +#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/ + /* Bit 93 Limbu */ +#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */ + /* Bit 94 Tai Le */ +#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ + /* Bit 95 New Tai Lue */ +#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ + /* Bit 96 Buginese */ +#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ + /* Bit 97 Glagolitic */ +#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */ + /* Bit 98 Tifinagh */ +#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */ + /* Bit 99 Yijing Hexagram Symbols */ +#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */ + /* Bit 100 Syloti Nagri */ +#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */ + /* Bit 101 Linear B Syllabary */ + /* Linear B Ideograms */ + /* Aegean Numbers */ +#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/ + /*U+10080-U+100FF*/ + /*U+10100-U+1013F*/ + /* Bit 102 Ancient Greek Numbers */ +#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/ + /* Bit 103 Ugaritic */ +#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/ + /* Bit 104 Old Persian */ +#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/ + /* Bit 105 Shavian */ +#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/ + /* Bit 106 Osmanya */ +#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/ + /* Bit 107 Cypriot Syllabary */ +#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/ + /* Bit 108 Kharoshthi */ +#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/ + /* Bit 109 Tai Xuan Jing Symbols */ +#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/ + /* Bit 110 Cuneiform */ + /* Cuneiform Numbers and Punctuation */ +#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/ + /*U+12400-U+1247F*/ + /* Bit 111 Counting Rod Numerals */ +#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/ + /* Bit 112 Sundanese */ +#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */ + /* Bit 113 Lepcha */ +#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */ + /* Bit 114 Ol Chiki */ +#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */ + /* Bit 115 Saurashtra */ +#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */ + /* Bit 116 Kayah Li */ +#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */ + /* Bit 117 Rejang */ +#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */ + /* Bit 118 Cham */ +#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */ + /* Bit 119 Ancient Symbols */ +#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/ + /* Bit 120 Phaistos Disc */ +#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/ + /* Bit 121 Carian */ + /* Lycian */ + /* Lydian */ +#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/ + /*U+10280-U+1029F*/ + /*U+10920-U+1093F*/ + /* Bit 122 Domino Tiles */ + /* Mahjong Tiles */ +#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/ + /*U+1F000-U+1F02F*/ + /* Bit 123-127 Reserved for process-internal usage */ + + + /*************************************************************************/ + /* */ + /* Some compilers have a very limited length of identifiers. */ + /* */ +#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) +#define HAVE_LIMIT_ON_IDENTS +#endif + + +#ifndef HAVE_LIMIT_ON_IDENTS + + + /*************************************************************************/ + /* */ + /* Here some alias #defines in order to be clearer. */ + /* */ + /* These are not always #defined to stay within the 31~character limit, */ + /* which some compilers have. */ + /* */ + /* Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern */ + /* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */ + /* If you get a warning with such a compiler, use the -i40 switch. */ + /* */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ + TT_UCR_ARABIC_PRESENTATIONS_A +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ + TT_UCR_ARABIC_PRESENTATIONS_B + +#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ + TT_UCR_COMBINING_DIACRITICS +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + TT_UCR_COMBINING_DIACRITICS_SYMB + + +#endif /* !HAVE_LIMIT_ON_IDENTS */ + + +FT_END_HEADER + +#endif /* TTNAMEID_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/tttables.h b/foreign/freetype2/freetype/tttables.h new file mode 100644 index 0000000..dfe3bcb --- /dev/null +++ b/foreign/freetype2/freetype/tttables.h @@ -0,0 +1,829 @@ +/***************************************************************************/ +/* */ +/* tttables.h */ +/* */ +/* Basic SFNT/TrueType tables definitions and interface */ +/* (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTTABLES_H_ +#define TTTABLES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* truetype_tables */ + /* */ + /* <Title> */ + /* TrueType Tables */ + /* */ + /* <Abstract> */ + /* TrueType specific table types and functions. */ + /* */ + /* <Description> */ + /* This section contains the definition of TrueType-specific tables */ + /* as well as some routines used to access and process them. */ + /* */ + /* <Order> */ + /* TT_Header */ + /* TT_HoriHeader */ + /* TT_VertHeader */ + /* TT_OS2 */ + /* TT_Postscript */ + /* TT_PCLT */ + /* TT_MaxProfile */ + /* */ + /* FT_Sfnt_Tag */ + /* FT_Get_Sfnt_Table */ + /* FT_Load_Sfnt_Table */ + /* FT_Sfnt_Table_Info */ + /* */ + /* FT_Get_CMap_Language_ID */ + /* FT_Get_CMap_Format */ + /* */ + /* FT_PARAM_TAG_UNPATENTED_HINTING */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Header */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType font header table. All */ + /* fields follow the TrueType specification. */ + /* */ + typedef struct TT_Header_ + { + FT_Fixed Table_Version; + FT_Fixed Font_Revision; + + FT_Long CheckSum_Adjust; + FT_Long Magic_Number; + + FT_UShort Flags; + FT_UShort Units_Per_EM; + + FT_Long Created [2]; + FT_Long Modified[2]; + + FT_Short xMin; + FT_Short yMin; + FT_Short xMax; + FT_Short yMax; + + FT_UShort Mac_Style; + FT_UShort Lowest_Rec_PPEM; + + FT_Short Font_Direction; + FT_Short Index_To_Loc_Format; + FT_Short Glyph_Data_Format; + + } TT_Header; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_HoriHeader */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType horizontal header, the `hhea' */ + /* table, as well as the corresponding horizontal metrics table, */ + /* i.e., the `hmtx' table. */ + /* */ + /* <Fields> */ + /* Version :: The table version. */ + /* */ + /* Ascender :: The font's ascender, i.e., the distance */ + /* from the baseline to the top-most of all */ + /* glyph points found in the font. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of the */ + /* glyphs found in the font (maybe ASCII). */ + /* */ + /* You should use the `sTypoAscender' field */ + /* of the OS/2 table instead if you want */ + /* the correct one. */ + /* */ + /* Descender :: The font's descender, i.e., the distance */ + /* from the baseline to the bottom-most of */ + /* all glyph points found in the font. It */ + /* is negative. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of the */ + /* glyphs found in the font (maybe ASCII). */ + /* */ + /* You should use the `sTypoDescender' */ + /* field of the OS/2 table instead if you */ + /* want the correct one. */ + /* */ + /* Line_Gap :: The font's line gap, i.e., the distance */ + /* to add to the ascender and descender to */ + /* get the BTB, i.e., the */ + /* baseline-to-baseline distance for the */ + /* font. */ + /* */ + /* advance_Width_Max :: This field is the maximum of all advance */ + /* widths found in the font. It can be */ + /* used to compute the maximum width of an */ + /* arbitrary string of text. */ + /* */ + /* min_Left_Side_Bearing :: The minimum left side bearing of all */ + /* glyphs within the font. */ + /* */ + /* min_Right_Side_Bearing :: The minimum right side bearing of all */ + /* glyphs within the font. */ + /* */ + /* xMax_Extent :: The maximum horizontal extent (i.e., the */ + /* `width' of a glyph's bounding box) for */ + /* all glyphs in the font. */ + /* */ + /* caret_Slope_Rise :: The rise coefficient of the cursor's */ + /* slope of the cursor (slope=rise/run). */ + /* */ + /* caret_Slope_Run :: The run coefficient of the cursor's */ + /* slope. */ + /* */ + /* Reserved :: 8~reserved bytes. */ + /* */ + /* metric_Data_Format :: Always~0. */ + /* */ + /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ + /* table -- this value can be smaller than */ + /* the total number of glyphs in the font. */ + /* */ + /* long_metrics :: A pointer into the `hmtx' table. */ + /* */ + /* short_metrics :: A pointer into the `hmtx' table. */ + /* */ + /* <Note> */ + /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ + /* be identical except for the names of their fields, */ + /* which are different. */ + /* */ + /* This ensures that a single function in the `ttload' */ + /* module is able to read both the horizontal and vertical */ + /* headers. */ + /* */ + typedef struct TT_HoriHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Width_Max; /* advance width maximum */ + + FT_Short min_Left_Side_Bearing; /* minimum left-sb */ + FT_Short min_Right_Side_Bearing; /* minimum right-sb */ + FT_Short xMax_Extent; /* xmax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* `HMTX' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_HoriHeader; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_VertHeader */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType vertical header, the `vhea' */ + /* table, as well as the corresponding vertical metrics table, i.e., */ + /* the `vmtx' table. */ + /* */ + /* <Fields> */ + /* Version :: The table version. */ + /* */ + /* Ascender :: The font's ascender, i.e., the distance */ + /* from the baseline to the top-most of */ + /* all glyph points found in the font. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of */ + /* the glyphs found in the font (maybe */ + /* ASCII). */ + /* */ + /* You should use the `sTypoAscender' */ + /* field of the OS/2 table instead if you */ + /* want the correct one. */ + /* */ + /* Descender :: The font's descender, i.e., the */ + /* distance from the baseline to the */ + /* bottom-most of all glyph points found */ + /* in the font. It is negative. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of */ + /* the glyphs found in the font (maybe */ + /* ASCII). */ + /* */ + /* You should use the `sTypoDescender' */ + /* field of the OS/2 table instead if you */ + /* want the correct one. */ + /* */ + /* Line_Gap :: The font's line gap, i.e., the distance */ + /* to add to the ascender and descender to */ + /* get the BTB, i.e., the */ + /* baseline-to-baseline distance for the */ + /* font. */ + /* */ + /* advance_Height_Max :: This field is the maximum of all */ + /* advance heights found in the font. It */ + /* can be used to compute the maximum */ + /* height of an arbitrary string of text. */ + /* */ + /* min_Top_Side_Bearing :: The minimum top side bearing of all */ + /* glyphs within the font. */ + /* */ + /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ + /* glyphs within the font. */ + /* */ + /* yMax_Extent :: The maximum vertical extent (i.e., the */ + /* `height' of a glyph's bounding box) for */ + /* all glyphs in the font. */ + /* */ + /* caret_Slope_Rise :: The rise coefficient of the cursor's */ + /* slope of the cursor (slope=rise/run). */ + /* */ + /* caret_Slope_Run :: The run coefficient of the cursor's */ + /* slope. */ + /* */ + /* caret_Offset :: The cursor's offset for slanted fonts. */ + /* This value is `reserved' in vmtx */ + /* version 1.0. */ + /* */ + /* Reserved :: 8~reserved bytes. */ + /* */ + /* metric_Data_Format :: Always~0. */ + /* */ + /* number_Of_HMetrics :: Number of VMetrics entries in the */ + /* `vmtx' table -- this value can be */ + /* smaller than the total number of glyphs */ + /* in the font. */ + /* */ + /* long_metrics :: A pointer into the `vmtx' table. */ + /* */ + /* short_metrics :: A pointer into the `vmtx' table. */ + /* */ + /* <Note> */ + /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ + /* be identical except for the names of their fields, */ + /* which are different. */ + /* */ + /* This ensures that a single function in the `ttload' */ + /* module is able to read both the horizontal and vertical */ + /* headers. */ + /* */ + typedef struct TT_VertHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Height_Max; /* advance height maximum */ + + FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */ + FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ + FT_Short yMax_Extent; /* xmax or ymax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_VertHeader; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_OS2 */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType OS/2 table. All fields */ + /* comply to the OpenType specification. */ + /* */ + /* Note that we now support old Mac fonts that do not include an OS/2 */ + /* table. In this case, the `version' field is always set to 0xFFFF. */ + /* */ + typedef struct TT_OS2_ + { + FT_UShort version; /* 0x0001 - more or 0xFFFF */ + FT_Short xAvgCharWidth; + FT_UShort usWeightClass; + FT_UShort usWidthClass; + FT_UShort fsType; + FT_Short ySubscriptXSize; + FT_Short ySubscriptYSize; + FT_Short ySubscriptXOffset; + FT_Short ySubscriptYOffset; + FT_Short ySuperscriptXSize; + FT_Short ySuperscriptYSize; + FT_Short ySuperscriptXOffset; + FT_Short ySuperscriptYOffset; + FT_Short yStrikeoutSize; + FT_Short yStrikeoutPosition; + FT_Short sFamilyClass; + + FT_Byte panose[10]; + + FT_ULong ulUnicodeRange1; /* Bits 0-31 */ + FT_ULong ulUnicodeRange2; /* Bits 32-63 */ + FT_ULong ulUnicodeRange3; /* Bits 64-95 */ + FT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + FT_Char achVendID[4]; + + FT_UShort fsSelection; + FT_UShort usFirstCharIndex; + FT_UShort usLastCharIndex; + FT_Short sTypoAscender; + FT_Short sTypoDescender; + FT_Short sTypoLineGap; + FT_UShort usWinAscent; + FT_UShort usWinDescent; + + /* only version 1 and higher: */ + + FT_ULong ulCodePageRange1; /* Bits 0-31 */ + FT_ULong ulCodePageRange2; /* Bits 32-63 */ + + /* only version 2 and higher: */ + + FT_Short sxHeight; + FT_Short sCapHeight; + FT_UShort usDefaultChar; + FT_UShort usBreakChar; + FT_UShort usMaxContext; + + /* only version 5 and higher: */ + + FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ + FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ + + } TT_OS2; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Postscript */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType PostScript table. All fields */ + /* comply to the TrueType specification. This structure does not */ + /* reference the PostScript glyph names, which can be nevertheless */ + /* accessed with the `ttpost' module. */ + /* */ + typedef struct TT_Postscript_ + { + FT_Fixed FormatType; + FT_Fixed italicAngle; + FT_Short underlinePosition; + FT_Short underlineThickness; + FT_ULong isFixedPitch; + FT_ULong minMemType42; + FT_ULong maxMemType42; + FT_ULong minMemType1; + FT_ULong maxMemType1; + + /* Glyph names follow in the file, but we don't */ + /* load them by default. See the ttpost.c file. */ + + } TT_Postscript; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_PCLT */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType PCLT table. All fields */ + /* comply to the TrueType specification. */ + /* */ + typedef struct TT_PCLT_ + { + FT_Fixed Version; + FT_ULong FontNumber; + FT_UShort Pitch; + FT_UShort xHeight; + FT_UShort Style; + FT_UShort TypeFamily; + FT_UShort CapHeight; + FT_UShort SymbolSet; + FT_Char TypeFace[16]; + FT_Char CharacterComplement[8]; + FT_Char FileName[6]; + FT_Char StrokeWeight; + FT_Char WidthType; + FT_Byte SerifStyle; + FT_Byte Reserved; + + } TT_PCLT; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_MaxProfile */ + /* */ + /* <Description> */ + /* The maximum profile is a table containing many max values, which */ + /* can be used to pre-allocate arrays. This ensures that no memory */ + /* allocation occurs during a glyph load. */ + /* */ + /* <Fields> */ + /* version :: The version number. */ + /* */ + /* numGlyphs :: The number of glyphs in this TrueType */ + /* font. */ + /* */ + /* maxPoints :: The maximum number of points in a */ + /* non-composite TrueType glyph. See also */ + /* the structure element */ + /* `maxCompositePoints'. */ + /* */ + /* maxContours :: The maximum number of contours in a */ + /* non-composite TrueType glyph. See also */ + /* the structure element */ + /* `maxCompositeContours'. */ + /* */ + /* maxCompositePoints :: The maximum number of points in a */ + /* composite TrueType glyph. See also the */ + /* structure element `maxPoints'. */ + /* */ + /* maxCompositeContours :: The maximum number of contours in a */ + /* composite TrueType glyph. See also the */ + /* structure element `maxContours'. */ + /* */ + /* maxZones :: The maximum number of zones used for */ + /* glyph hinting. */ + /* */ + /* maxTwilightPoints :: The maximum number of points in the */ + /* twilight zone used for glyph hinting. */ + /* */ + /* maxStorage :: The maximum number of elements in the */ + /* storage area used for glyph hinting. */ + /* */ + /* maxFunctionDefs :: The maximum number of function */ + /* definitions in the TrueType bytecode for */ + /* this font. */ + /* */ + /* maxInstructionDefs :: The maximum number of instruction */ + /* definitions in the TrueType bytecode for */ + /* this font. */ + /* */ + /* maxStackElements :: The maximum number of stack elements used */ + /* during bytecode interpretation. */ + /* */ + /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ + /* used for glyph hinting. */ + /* */ + /* maxComponentElements :: The maximum number of simple (i.e., non- */ + /* composite) glyphs in a composite glyph. */ + /* */ + /* maxComponentDepth :: The maximum nesting depth of composite */ + /* glyphs. */ + /* */ + /* <Note> */ + /* This structure is only used during font loading. */ + /* */ + typedef struct TT_MaxProfile_ + { + FT_Fixed version; + FT_UShort numGlyphs; + FT_UShort maxPoints; + FT_UShort maxContours; + FT_UShort maxCompositePoints; + FT_UShort maxCompositeContours; + FT_UShort maxZones; + FT_UShort maxTwilightPoints; + FT_UShort maxStorage; + FT_UShort maxFunctionDefs; + FT_UShort maxInstructionDefs; + FT_UShort maxStackElements; + FT_UShort maxSizeOfInstructions; + FT_UShort maxComponentElements; + FT_UShort maxComponentDepth; + + } TT_MaxProfile; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Sfnt_Tag */ + /* */ + /* <Description> */ + /* An enumeration used to specify the index of an SFNT table. */ + /* Used in the @FT_Get_Sfnt_Table API function. */ + /* */ + /* <Values> */ + /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ + /* */ + /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ + /* */ + /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ + /* */ + /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ + /* */ + /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader struture. */ + /* */ + /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ + /* */ + /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ + /* */ + typedef enum FT_Sfnt_Tag_ + { + FT_SFNT_HEAD, + FT_SFNT_MAXP, + FT_SFNT_OS2, + FT_SFNT_HHEA, + FT_SFNT_VHEA, + FT_SFNT_POST, + FT_SFNT_PCLT, + + FT_SFNT_MAX + + } FT_Sfnt_Tag; + + /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ + /* values instead */ +#define ft_sfnt_head FT_SFNT_HEAD +#define ft_sfnt_maxp FT_SFNT_MAXP +#define ft_sfnt_os2 FT_SFNT_OS2 +#define ft_sfnt_hhea FT_SFNT_HHEA +#define ft_sfnt_vhea FT_SFNT_VHEA +#define ft_sfnt_post FT_SFNT_POST +#define ft_sfnt_pclt FT_SFNT_PCLT + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Table */ + /* */ + /* <Description> */ + /* Return a pointer to a given SFNT table within a face. */ + /* */ + /* <Input> */ + /* face :: A handle to the source. */ + /* */ + /* tag :: The index of the SFNT table. */ + /* */ + /* <Return> */ + /* A type-less pointer to the table. This will be~0 in case of */ + /* error, or if the corresponding table was not found *OR* loaded */ + /* from the file. */ + /* */ + /* Use a typecast according to `tag' to access the structure */ + /* elements. */ + /* */ + /* <Note> */ + /* The table is owned by the face object and disappears with it. */ + /* */ + /* This function is only useful to access SFNT tables that are loaded */ + /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ + /* a list. */ + /* */ + /* Here an example how to access the `vhea' table: */ + /* */ + /* { */ + /* TT_VertHeader* vert_header; */ + /* */ + /* */ + /* vert_header = */ + /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ + /* } */ + /* */ + FT_EXPORT( void* ) + FT_Get_Sfnt_Table( FT_Face face, + FT_Sfnt_Tag tag ); + + + /************************************************************************** + * + * @function: + * FT_Load_Sfnt_Table + * + * @description: + * Load any font table into client memory. + * + * @input: + * face :: + * A handle to the source face. + * + * tag :: + * The four-byte tag of the table to load. Use the value~0 if you want + * to access the whole font file. Otherwise, you can use one of the + * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new + * one with @FT_MAKE_TAG. + * + * offset :: + * The starting offset in the table (or file if tag == 0). + * + * @output: + * buffer :: + * The target buffer address. The client must ensure that the memory + * array is big enough to hold the data. + * + * @inout: + * length :: + * If the `length' parameter is NULL, then try to load the whole table. + * Return an error code if it fails. + * + * Else, if `*length' is~0, exit immediately while returning the + * table's (or file) full size in it. + * + * Else the number of bytes to read from the table or file, from the + * starting offset. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If you need to determine the table's length you should first call this + * function with `*length' set to~0, as in the following example: + * + * { + * FT_ULong length = 0; + * + * + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } + * + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } + * + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * } + * + * Note that structures like @TT_Header or @TT_OS2 can't be used with + * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that + * those structures depend on the processor architecture, with varying + * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). + * + */ + FT_EXPORT( FT_Error ) + FT_Load_Sfnt_Table( FT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); + + + /************************************************************************** + * + * @function: + * FT_Sfnt_Table_Info + * + * @description: + * Return information on an SFNT table. + * + * @input: + * face :: + * A handle to the source face. + * + * table_index :: + * The index of an SFNT table. The function returns + * FT_Err_Table_Missing for an invalid value. + * + * @inout: + * tag :: + * The name tag of the SFNT table. If the value is NULL, `table_index' + * is ignored, and `length' returns the number of SFNT tables in the + * font. + * + * @output: + * length :: + * The length of the SFNT table (or the number of SFNT tables, depending + * on `tag'). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While parsing fonts, FreeType handles SFNT tables with length zero as + * missing. + * + */ + FT_EXPORT( FT_Error ) + FT_Sfnt_Table_Info( FT_Face face, + FT_UInt table_index, + FT_ULong *tag, + FT_ULong *length ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_CMap_Language_ID */ + /* */ + /* <Description> */ + /* Return TrueType/sfnt specific cmap language ID. Definitions of */ + /* language ID values are in `ttnameid.h'. */ + /* */ + /* <Input> */ + /* charmap :: */ + /* The target charmap. */ + /* */ + /* <Return> */ + /* The language ID of `charmap'. If `charmap' doesn't belong to a */ + /* TrueType/sfnt face, just return~0 as the default value. */ + /* */ + /* For a format~14 cmap (to access Unicode IVS), the return value is */ + /* 0xFFFFFFFF. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_CMap_Language_ID( FT_CharMap charmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_CMap_Format */ + /* */ + /* <Description> */ + /* Return TrueType/sfnt specific cmap format. */ + /* */ + /* <Input> */ + /* charmap :: */ + /* The target charmap. */ + /* */ + /* <Return> */ + /* The format of `charmap'. If `charmap' doesn't belong to a */ + /* TrueType/sfnt face, return -1. */ + /* */ + FT_EXPORT( FT_Long ) + FT_Get_CMap_Format( FT_CharMap charmap ); + + /* */ + + +FT_END_HEADER + +#endif /* TTTABLES_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/tttags.h b/foreign/freetype2/freetype/tttags.h new file mode 100644 index 0000000..f3c9aa5 --- /dev/null +++ b/foreign/freetype2/freetype/tttags.h @@ -0,0 +1,111 @@ +/***************************************************************************/ +/* */ +/* tttags.h */ +/* */ +/* Tags for TrueType and OpenType tables (specification only). */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTAGS_H_ +#define TTAGS_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + +#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) +#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) +#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) +#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) +#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) +#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) +#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) +#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) +#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) +#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) +#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) +#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) +#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) +#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) +#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) +#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) +#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) +#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) +#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) +#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) +#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) +#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) +#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) +#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) +#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) +#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) +#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) +#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) +#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) +#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) +#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) +#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) +#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) +#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) +#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) +#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) +#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) +#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) + + +FT_END_HEADER + +#endif /* TTAGS_H_ */ + + +/* END */ diff --git a/foreign/freetype2/freetype/ttunpat.h b/foreign/freetype2/freetype/ttunpat.h new file mode 100644 index 0000000..ca4676b --- /dev/null +++ b/foreign/freetype2/freetype/ttunpat.h @@ -0,0 +1,63 @@ +/***************************************************************************/ +/* */ +/* ttunpat.h */ +/* */ +/* Definitions for the unpatented TrueType hinting system. */ +/* Obsolete, retained for backwards compatibility. */ +/* */ +/* Copyright 2003-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* Written by Graham Asher <graham.asher@btinternet.com> */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTUNPAT_H_ +#define TTUNPAT_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_UNPATENTED_HINTING + * + * @description: + * Deprecated. + * + * Previously: A constant used as the tag of an @FT_Parameter structure to + * indicate that unpatented methods only should be used by the TrueType + * bytecode interpreter for a typeface opened by @FT_Open_Face. + * + */ +#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) + + /* */ + + +FT_END_HEADER + + +#endif /* TTUNPAT_H_ */ + + +/* END */ diff --git a/foreign/freetype2/ft2build.h b/foreign/freetype2/ft2build.h new file mode 100644 index 0000000..c89cb46 --- /dev/null +++ b/foreign/freetype2/ft2build.h @@ -0,0 +1,42 @@ +/***************************************************************************/ +/* */ +/* ft2build.h */ +/* */ +/* FreeType 2 build and setup macros. */ +/* */ +/* Copyright 1996-2016 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This is the `entry point' for FreeType header file inclusions. It is */ + /* the only header file which should be included directly; all other */ + /* FreeType header files should be accessed with macro names (after */ + /* including `ft2build.h'). */ + /* */ + /* A typical example is */ + /* */ + /* #include <ft2build.h> */ + /* #include FT_FREETYPE_H */ + /* */ + /*************************************************************************/ + + +#ifndef FT2BUILD_H_ +#define FT2BUILD_H_ + +#include <freetype/config/ftheader.h> + +#endif /* FT2BUILD_H_ */ + + +/* END */ diff --git a/foreign/gl/glext.h b/foreign/gl/glext.h new file mode 100644 index 0000000..c6a233a --- /dev/null +++ b/foreign/gl/glext.h @@ -0,0 +1,11124 @@ +#ifndef __glext_h_ +#define __glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 24756 $ on $Date: 2014-01-14 03:42:29 -0800 (Tue, 14 Jan 2014) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include <windows.h> +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20140114 + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include <stddef.h> +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef unsigned short GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include <inttypes.h> +#elif defined(__sun__) || defined(__digital__) +#include <inttypes.h> +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include <inttypes.h> +#elif defined(__SCO__) || defined(__USLC__) +#include <stdint.h> +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include <stdint.h> +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include <inttypes.h> +#endif +#endif +typedef uint64_t GLuint64; +typedef int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef unsigned short GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_MIN_SPARSE_LEVEL_ARB 0x919B +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +typedef int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/foreign/stb_image.h b/foreign/stb_image.h new file mode 100644 index 0000000..0a9de39 --- /dev/null +++ b/foreign/stb_image.h @@ -0,0 +1,6509 @@ +/* stb_image - v2.08 - public domain image loader - http://nothings.org/stb_image.h + no warranty implied; use at your own risk + + Do this: + #define STB_IMAGE_IMPLEMENTATION + before you include this file in *one* C or C++ file to create the implementation. + + // i.e. it should look like this: + #include ... + #include ... + #include ... + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + + You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. + And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free + + + QUICK NOTES: + Primarily of interest to game developers and other people who can + avoid problematic images and only need the trivial interface + + JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) + PNG 1/2/4/8-bit-per-channel (16 bpc not supported) + + TGA (not sure what subset, if a subset) + BMP non-1bpp, non-RLE + PSD (composited view only, no extra channels, 8/16 bit-per-channel) + + GIF (*comp always reports as 4-channel) + HDR (radiance rgbE format) + PIC (Softimage PIC) + PNM (PPM and PGM binary only) + + Animated GIF still needs a proper API, but here's one way to do it: + http://gist.github.com/urraka/685d9a6340b26b830d49 + + - decode from memory or through FILE (define STBI_NO_STDIO to remove code) + - decode from arbitrary I/O callbacks + - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) + + Full documentation under "DOCUMENTATION" below. + + + Revision 2.00 release notes: + + - Progressive JPEG is now supported. + + - PPM and PGM binary formats are now supported, thanks to Ken Miller. + + - x86 platforms now make use of SSE2 SIMD instructions for + JPEG decoding, and ARM platforms can use NEON SIMD if requested. + This work was done by Fabian "ryg" Giesen. SSE2 is used by + default, but NEON must be enabled explicitly; see docs. + + With other JPEG optimizations included in this version, we see + 2x speedup on a JPEG on an x86 machine, and a 1.5x speedup + on a JPEG on an ARM machine, relative to previous versions of this + library. The same results will not obtain for all JPGs and for all + x86/ARM machines. (Note that progressive JPEGs are significantly + slower to decode than regular JPEGs.) This doesn't mean that this + is the fastest JPEG decoder in the land; rather, it brings it + closer to parity with standard libraries. If you want the fastest + decode, look elsewhere. (See "Philosophy" section of docs below.) + + See final bullet items below for more info on SIMD. + + - Added STBI_MALLOC, STBI_REALLOC, and STBI_FREE macros for replacing + the memory allocator. Unlike other STBI libraries, these macros don't + support a context parameter, so if you need to pass a context in to + the allocator, you'll have to store it in a global or a thread-local + variable. + + - Split existing STBI_NO_HDR flag into two flags, STBI_NO_HDR and + STBI_NO_LINEAR. + STBI_NO_HDR: suppress implementation of .hdr reader format + STBI_NO_LINEAR: suppress high-dynamic-range light-linear float API + + - You can suppress implementation of any of the decoders to reduce + your code footprint by #defining one or more of the following + symbols before creating the implementation. + + STBI_NO_JPEG + STBI_NO_PNG + STBI_NO_BMP + STBI_NO_PSD + STBI_NO_TGA + STBI_NO_GIF + STBI_NO_HDR + STBI_NO_PIC + STBI_NO_PNM (.ppm and .pgm) + + - You can request *only* certain decoders and suppress all other ones + (this will be more forward-compatible, as addition of new decoders + doesn't require you to disable them explicitly): + + STBI_ONLY_JPEG + STBI_ONLY_PNG + STBI_ONLY_BMP + STBI_ONLY_PSD + STBI_ONLY_TGA + STBI_ONLY_GIF + STBI_ONLY_HDR + STBI_ONLY_PIC + STBI_ONLY_PNM (.ppm and .pgm) + + Note that you can define multiples of these, and you will get all + of them ("only x" and "only y" is interpreted to mean "only x&y"). + + - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still + want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB + + - Compilation of all SIMD code can be suppressed with + #define STBI_NO_SIMD + It should not be necessary to disable SIMD unless you have issues + compiling (e.g. using an x86 compiler which doesn't support SSE + intrinsics or that doesn't support the method used to detect + SSE2 support at run-time), and even those can be reported as + bugs so I can refine the built-in compile-time checking to be + smarter. + + - The old STBI_SIMD system which allowed installing a user-defined + IDCT etc. has been removed. If you need this, don't upgrade. My + assumption is that almost nobody was doing this, and those who + were will find the built-in SIMD more satisfactory anyway. + + - RGB values computed for JPEG images are slightly different from + previous versions of stb_image. (This is due to using less + integer precision in SIMD.) The C code has been adjusted so + that the same RGB values will be computed regardless of whether + SIMD support is available, so your app should always produce + consistent results. But these results are slightly different from + previous versions. (Specifically, about 3% of available YCbCr values + will compute different RGB results from pre-1.49 versions by +-1; + most of the deviating values are one smaller in the G channel.) + + - If you must produce consistent results with previous versions of + stb_image, #define STBI_JPEG_OLD and you will get the same results + you used to; however, you will not get the SIMD speedups for + the YCbCr-to-RGB conversion step (although you should still see + significant JPEG speedup from the other changes). + + Please note that STBI_JPEG_OLD is a temporary feature; it will be + removed in future versions of the library. It is only intended for + near-term back-compatibility use. + + + Latest revision history: + 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA + 2.07 (2015-09-13) partial animated GIF support + limited 16-bit PSD support + minor bugs, code cleanup, and compiler warnings + 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value + 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning + 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit + 2.03 (2015-04-12) additional corruption checking + stbi_set_flip_vertically_on_load + fix NEON support; fix mingw support + 2.02 (2015-01-19) fix incorrect assert, fix warning + 2.01 (2015-01-17) fix various warnings + 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG + 2.00 (2014-12-25) optimize JPEG, including x86 SSE2 & ARM NEON SIMD + progressive JPEG + PGM/PPM support + STBI_MALLOC,STBI_REALLOC,STBI_FREE + STBI_NO_*, STBI_ONLY_* + GIF bugfix + 1.48 (2014-12-14) fix incorrectly-named assert() + 1.47 (2014-12-14) 1/2/4-bit PNG support (both grayscale and paletted) + optimize PNG + fix bug in interlaced PNG with user-specified channel count + + See end of file for full revision history. + + + ============================ Contributors ========================= + + Image formats Bug fixes & warning fixes + Sean Barrett (jpeg, png, bmp) Marc LeBlanc + Nicolas Schulz (hdr, psd) Christpher Lloyd + Jonathan Dummer (tga) Dave Moore + Jean-Marc Lienher (gif) Won Chun + Tom Seddon (pic) the Horde3D community + Thatcher Ulrich (psd) Janez Zemva + Ken Miller (pgm, ppm) Jonathan Blow + urraka@github (animated gif) Laurent Gomila + Aruelien Pocheville + Ryamond Barbiero + David Woo + Extensions, features Martin Golini + Jetro Lauha (stbi_info) Roy Eltham + Martin "SpartanJ" Golini (stbi_info) Luke Graham + James "moose2000" Brown (iPhone PNG) Thomas Ruf + Ben "Disch" Wenger (io callbacks) John Bartholomew + Omar Cornut (1/2/4-bit PNG) Ken Hamada + Nicolas Guillemot (vertical flip) Cort Stratton + Richard Mitton (16-bit PSD) Blazej Dariusz Roszkowski + Thibault Reuille + Paul Du Bois + Guillaume George + Jerry Jansson + Hayaki Saito + Johan Duparc + Ronny Chevalier + Optimizations & bugfixes Michal Cichon + Fabian "ryg" Giesen Tero Hanninen + Arseny Kapoulkine Sergio Gonzalez + Cass Everitt + Engin Manap + If your name should be here but Martins Mozeiko + isn't, let Sean know. Joseph Thomson + Phil Jordan + Nathan Reed + Michaelangel007@github + Nick Verigakis + +LICENSE + +This software is in the public domain. Where that dedication is not +recognized, you are granted a perpetual, irrevocable license to copy, +distribute, and modify this file as you see fit. + +*/ + +#ifndef STBI_INCLUDE_STB_IMAGE_H +#define STBI_INCLUDE_STB_IMAGE_H + +// DOCUMENTATION +// +// Limitations: +// - no 16-bit-per-channel PNG +// - no 12-bit-per-channel JPEG +// - no JPEGs with arithmetic coding +// - no 1-bit BMP +// - GIF always returns *comp=4 +// +// Basic usage (see HDR discussion below for HDR usage): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// // ... but 'n' will always be the number that it would have been if you said 0 +// stbi_image_free(data) +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *comp -- outputs # of image components in image file +// int req_comp -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data, or NULL on an allocation failure or if the image is +// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. +// If req_comp is non-zero, *comp has the number of components that _would_ +// have been output otherwise. E.g. if you set req_comp to 4, you will always +// get RGBA output, but you can check *comp to see if it's trivially opaque +// because e.g. there were only 3 channels in the source image. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *comp will be unchanged. The function stbi_failure_reason() +// can be queried for an extremely brief, end-user unfriendly explanation +// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid +// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. +// +// =========================================================================== +// +// Philosophy +// +// stb libraries are designed with the following priorities: +// +// 1. easy to use +// 2. easy to maintain +// 3. good performance +// +// Sometimes I let "good performance" creep up in priority over "easy to maintain", +// and for best performance I may provide less-easy-to-use APIs that give higher +// performance, in addition to the easy to use ones. Nevertheless, it's important +// to keep in mind that from the standpoint of you, a client of this library, +// all you care about is #1 and #3, and stb libraries do not emphasize #3 above all. +// +// Some secondary priorities arise directly from the first two, some of which +// make more explicit reasons why performance can't be emphasized. +// +// - Portable ("ease of use") +// - Small footprint ("easy to maintain") +// - No dependencies ("ease of use") +// +// =========================================================================== +// +// I/O callbacks +// +// I/O callbacks allow you to read from arbitrary sources, like packaged +// files or some other source. Data read from callbacks are processed +// through a small internal buffer (currently 128 bytes) to try to reduce +// overhead. +// +// The three functions you must define are "read" (reads some bytes of data), +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// +// =========================================================================== +// +// SIMD support +// +// The JPEG decoder will try to automatically use SIMD kernels on x86 when +// supported by the compiler. For ARM Neon support, you must explicitly +// request it. +// +// (The old do-it-yourself SIMD API is no longer supported in the current +// code.) +// +// On x86, SSE2 will automatically be used when available based on a run-time +// test; if not, the generic C versions are used as a fall-back. On ARM targets, +// the typical path is to have separate builds for NEON and non-NEON devices +// (at least this is true for iOS and Android). Therefore, the NEON support is +// toggled by a build flag: define STBI_NEON to get NEON loops. +// +// The output of the JPEG decoder is slightly different from versions where +// SIMD support was introduced (that is, for versions before 1.49). The +// difference is only +-1 in the 8-bit RGB channels, and only on a small +// fraction of pixels. You can force the pre-1.49 behavior by defining +// STBI_JPEG_OLD, but this will disable some of the SIMD decoding path +// and hence cost some performance. +// +// If for some reason you do not want to use any of SIMD code, or if +// you have issues compiling it, you can disable it entirely by +// defining STBI_NO_SIMD. +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image now supports loading HDR images in general, and currently +// the Radiance .HDR file format, although the support is provided +// generically. You can still load any file through the existing interface; +// if you attempt to load an HDR file, it will be automatically remapped to +// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); +// +// =========================================================================== +// +// iPhone PNG support: +// +// By default we convert iphone-formatted PNGs back to RGB, even though +// they are internally encoded differently. You can disable this conversion +// by by calling stbi_convert_iphone_png_to_rgb(0), in which case +// you will always just get the native iphone "format" through (which +// is BGR stored in RGB). +// +// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per +// pixel to remove any premultiplied alpha *only* if the image file explicitly +// says there's premultiplied data (currently only happens in iPhone images, +// and only if iPhone convert-to-rgb processing is on). +// + + +#ifndef STBI_NO_STDIO +#include <stdio.h> +#endif // STBI_NO_STDIO + +#define STBI_VERSION 1 + +enum +{ + STBI_default = 0, // only used for req_comp + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 +}; + +typedef unsigned char stbi_uc; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef STB_IMAGE_STATIC +#define STBIDEF static +#else +#define STBIDEF extern +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// PRIMARY API - works on images of any type +// + +// +// load image by filename, open file, or memory buffer +// + +typedef struct +{ + int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read + void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative + int (*eof) (void *user); // returns nonzero if we are at end of file/data +} stbi_io_callbacks; + +STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); +STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *comp, int req_comp); +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *comp, int req_comp); + +#ifndef STBI_NO_STDIO +STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +// for stbi_load_from_file, file pointer is left pointing immediately after image +#endif + +#ifndef STBI_NO_LINEAR + STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); + STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); + STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp); + + #ifndef STBI_NO_STDIO + STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); + #endif +#endif + +#ifndef STBI_NO_HDR + STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); + STBIDEF void stbi_hdr_to_ldr_scale(float scale); +#endif + +#ifndef STBI_NO_LINEAR + STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); + STBIDEF void stbi_ldr_to_hdr_scale(float scale); +#endif // STBI_NO_HDR + +// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename); +STBIDEF int stbi_is_hdr_from_file(FILE *f); +#endif // STBI_NO_STDIO + + +// get a VERY brief reason for failure +// NOT THREADSAFE +STBIDEF const char *stbi_failure_reason (void); + +// free the loaded image -- this is just free() +STBIDEF void stbi_image_free (void *retval_from_stbi_load); + +// get image dimensions & components without fully decoding +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); + +#endif + + + +// for image formats that explicitly notate that they have premultiplied alpha, +// we just return the colors as stored in the file. set this flag to force +// unpremultiplication. results are undefined if the unpremultiply overflow. +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); + +// indicate whether we should process iphone images back to canonical format, +// or just pass them through "as-is" +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); + +// flip the image vertically, so the first pixel in the output array is the bottom left +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); + +// ZLIB client - used by PNG, available for other purposes + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); +STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + +STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBI_INCLUDE_STB_IMAGE_H + +#ifdef STB_IMAGE_IMPLEMENTATION + +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ + || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ + || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ + || defined(STBI_ONLY_ZLIB) + #ifndef STBI_ONLY_JPEG + #define STBI_NO_JPEG + #endif + #ifndef STBI_ONLY_PNG + #define STBI_NO_PNG + #endif + #ifndef STBI_ONLY_BMP + #define STBI_NO_BMP + #endif + #ifndef STBI_ONLY_PSD + #define STBI_NO_PSD + #endif + #ifndef STBI_ONLY_TGA + #define STBI_NO_TGA + #endif + #ifndef STBI_ONLY_GIF + #define STBI_NO_GIF + #endif + #ifndef STBI_ONLY_HDR + #define STBI_NO_HDR + #endif + #ifndef STBI_ONLY_PIC + #define STBI_NO_PIC + #endif + #ifndef STBI_ONLY_PNM + #define STBI_NO_PNM + #endif +#endif + +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#define STBI_NO_ZLIB +#endif + + +#include <stdarg.h> +#include <stddef.h> // ptrdiff_t on osx +#include <stdlib.h> +#include <string.h> + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +#include <math.h> // ldexp +#endif + +#ifndef STBI_NO_STDIO +#include <stdio.h> +#endif + +#ifndef STBI_ASSERT +#include <assert.h> +#define STBI_ASSERT(x) assert(x) +#endif + + +#ifndef _MSC_VER + #ifdef __cplusplus + #define stbi_inline inline + #else + #define stbi_inline + #endif +#else + #define stbi_inline __forceinline +#endif + + +#ifdef _MSC_VER +typedef unsigned short stbi__uint16; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; +#else +#include <stdint.h> +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif + +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif + +#ifdef STBI_HAS_LROTL + #define stbi_lrot(x,y) _lrotl(x,y) +#else + #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) +#endif + +#if defined(STBI_MALLOC) && defined(STBI_FREE) && defined(STBI_REALLOC) +// ok +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) +// ok +#else +#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC." +#endif + +#ifndef STBI_MALLOC +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p,sz) realloc(p,sz) +#define STBI_FREE(p) free(p) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +// NOTE: not clear do we actually need this for the 64-bit path? +// gcc doesn't support sse2 intrinsics unless you compile with -msse2, +// (but compiling with -msse2 allows the compiler to use SSE2 everywhere; +// this is just broken and gcc are jerks for not fixing it properly +// http://www.virtualdub.org/blog/pivot/entry.php?id=363 ) +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +// +// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the +// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. +// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not +// simultaneously enabling "-mstackrealign". +// +// See https://github.com/nothings/stb/issues/81 for more information. +// +// So default to no SSE2 on 32-bit MinGW. If you've read this far and added +// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && defined(STBI__X86_TARGET) +#define STBI_SSE2 +#include <emmintrin.h> + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 // not VC6 +#include <intrin.h> // __cpuid +static int stbi__cpuid3(void) +{ + int info[4]; + __cpuid(info,1); + return info[3]; +} +#else +static int stbi__cpuid3(void) +{ + int res; + __asm { + mov eax,1 + cpuid + mov res,edx + } + return res; +} +#endif + +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +static int stbi__sse2_available() +{ + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#else // assume GCC-style if not VC++ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) + +static int stbi__sse2_available() +{ +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later + // GCC 4.8+ has a nice way to do this + return __builtin_cpu_supports("sse2"); +#else + // portable way to do this, preferably without using GCC inline ASM? + // just bail for now. + return 0; +#endif +} +#endif +#endif + +// ARM NEON +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include <arm_neon.h> +// assume GCC or Clang on ARM targets +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct +{ + stbi__uint32 img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; + + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; +} stbi__context; + + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; +} + +// initialize a callback-based context +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) +{ + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; +} + +#ifndef STBI_NO_STDIO + +static int stbi__stdio_read(void *user, char *data, int size) +{ + return (int) fread(data,1,size,(FILE*) user); +} + +static void stbi__stdio_skip(void *user, int n) +{ + fseek((FILE*) user, n, SEEK_CUR); +} + +static int stbi__stdio_eof(void *user) +{ + return feof((FILE*) user); +} + +static stbi_io_callbacks stbi__stdio_callbacks = +{ + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, +}; + +static void stbi__start_file(stbi__context *s, FILE *f) +{ + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); +} + +//static void stop_file(stbi__context *s) { } + +#endif // !STBI_NO_STDIO + +static void stbi__rewind(stbi__context *s) +{ + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; +} + +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static stbi_uc *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNG +static int stbi__png_test(stbi__context *s); +static stbi_uc *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_BMP +static int stbi__bmp_test(stbi__context *s); +static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_TGA +static int stbi__tga_test(stbi__context *s); +static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s); +static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_HDR +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_test(stbi__context *s); +static stbi_uc *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_GIF +static int stbi__gif_test(stbi__context *s); +static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNM +static int stbi__pnm_test(stbi__context *s); +static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +// this is not threadsafe +static const char *stbi__g_failure_reason; + +STBIDEF const char *stbi_failure_reason(void) +{ + return stbi__g_failure_reason; +} + +static int stbi__err(const char *str) +{ + stbi__g_failure_reason = str; + return 0; +} + +static void *stbi__malloc(size_t size) +{ + return STBI_MALLOC(size); +} + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS + #define stbi__err(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) + #define stbi__err(x,y) stbi__err(y) +#else + #define stbi__err(x,y) stbi__err(x) +#endif + +#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) + +STBIDEF void stbi_image_free(void *retval_from_stbi_load) +{ + STBI_FREE(retval_from_stbi_load); +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_HDR +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +static int stbi__vertically_flip_on_load = 0; + +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load = flag_true_if_should_flip; +} + +static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + #ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_PNG + if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_GIF + if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_PSD + if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_PIC + if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp); + #endif + #ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp); + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x,y,comp,req_comp); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } + #endif + + #ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s,x,y,comp,req_comp); + #endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); + + if (stbi__vertically_flip_on_load && result != NULL) { + int w = *x, h = *y; + int depth = req_comp ? req_comp : *comp; + int row,col,z; + stbi_uc temp; + + // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once + for (row = 0; row < (h>>1); row++) { + for (col = 0; col < w; col++) { + for (z = 0; z < depth; z++) { + temp = result[(row * w + col) * depth + z]; + result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; + result[((h - row - 1) * w + col) * depth + z] = temp; + } + } + } + } + + return result; +} + +#ifndef STBI_NO_HDR +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) +{ + if (stbi__vertically_flip_on_load && result != NULL) { + int w = *x, h = *y; + int depth = req_comp ? req_comp : *comp; + int row,col,z; + float temp; + + // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once + for (row = 0; row < (h>>1); row++) { + for (col = 0; col < w; col++) { + for (z = 0; z < depth; z++) { + temp = result[(row * w + col) * depth + z]; + result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; + result[((h - row - 1) * w + col) * depth + z] = temp; + } + } + } + } +} +#endif + +#ifndef STBI_NO_STDIO + +static FILE *stbi__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f=0; +#else + f = fopen(filename, mode); +#endif + return f; +} + + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_file(&s,f); + result = stbi__load_flip(&s,x,y,comp,req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} +#endif //!STBI_NO_STDIO + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_flip(&s,x,y,comp,req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__load_flip(&s,x,y,comp,req_comp); +} + +#ifndef STBI_NO_LINEAR +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp); + if (hdr_data) + stbi__float_postprocess(hdr_data,x,y,comp,req_comp); + return hdr_data; + } + #endif + data = stbi__load_flip(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); +} + +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_file(&s,f); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} +#endif // !STBI_NO_STDIO + +#endif // !STBI_NO_LINEAR + +// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is +// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always +// reports false! + +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; + #endif +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result=0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +STBIDEF int stbi_is_hdr_from_file(FILE *f) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_file(&s,f); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(f); + return 0; + #endif +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; + #endif +} + +static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; +static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; + +#ifndef STBI_NO_LINEAR +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +#endif + +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } + + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum +{ + STBI__SCAN_load=0, + STBI__SCAN_type, + STBI__SCAN_header +}; + +static void stbi__refill_buffer(stbi__context *s) +{ + int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start+1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +stbi_inline static int stbi__at_eof(stbi__context *s) +{ + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} + +static void stbi__skip(stbi__context *s, int n) +{ + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} + +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) +{ + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); + res = (count == (n-blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } + + if (s->img_buffer+n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; +} + +static int stbi__get16be(stbi__context *s) +{ + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} + +static stbi__uint32 stbi__get32be(stbi__context *s) +{ + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); +} + +#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) +// nothing +#else +static int stbi__get16le(stbi__context *s) +{ + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); +} +#endif + +#ifndef STBI_NO_BMP +static stbi__uint32 stbi__get32le(stbi__context *s) +{ + stbi__uint32 z = stbi__get16le(s); + return z + (stbi__get16le(s) << 16); +} +#endif + +#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings + + +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static stbi_uc stbi__compute_y(int r, int g, int b) +{ + return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); +} + +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i,j; + unsigned char *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *) stbi__malloc(req_comp * x * y); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j=0; j < (int) y; ++j) { + unsigned char *src = data + j * x * img_n ; + unsigned char *dest = good + j * x * req_comp; + + #define COMBO(a,b) ((a)*8+(b)) + #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (COMBO(img_n, req_comp)) { + CASE(1,2) dest[0]=src[0], dest[1]=255; break; + CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; + CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; + CASE(2,1) dest[0]=src[0]; break; + CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; + CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; + CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; + CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; + CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break; + CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; + CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; + CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; + default: STBI_ASSERT(0); + } + #undef CASE + } + + STBI_FREE(data); + return good; +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +{ + int i,k,n; + float *output = (float *) stbi__malloc(x * y * comp * sizeof(float)); + if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + } + if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; + } + STBI_FREE(data); + return output; +} +#endif + +#ifndef STBI_NO_HDR +#define stbi__float2int(x) ((int) (x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) +{ + int i,k,n; + stbi_uc *output = (stbi_uc *) stbi__malloc(x * y * comp); + if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + if (k < comp) { + float z = data[i*comp+k] * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + } + STBI_FREE(data); + return output; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly + +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct +{ + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi_uc dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + +// sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + +// definition of jpeg image component + struct + { + int id; + int h,v; + int tq; + int hd,ha; + int dc_pred; + + int x,y,w2,h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + + int scan_n, order[4]; + int restart_interval, todo; + +// kernels + void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); +} stbi__jpeg; + +static int stbi__build_huffman(stbi__huffman *h, int *count) +{ + int i,j,k=0,code; + // build size list for each symbol (from JPEG spec) + for (i=0; i < 16; ++i) + for (j=0; j < count[i]; ++j) + h->size[k++] = (stbi_uc) (i+1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for(j=1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16) (code++); + if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16-j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i=0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS-s); + int m = 1 << (FAST_BITS-s); + for (j=0; j < m; ++j) { + h->fast[c+j] = (stbi_uc) i; + } + } + } + return 1; +} + +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) +{ + int i; + for (i=0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) k += (-1 << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16) ((k << 8) + (run << 4) + (len + magbits)); + } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) +{ + do { + int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + if (c != 0) { + j->marker = (unsigned char) c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} + +// (1 << n) - 1 +static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; + +// decode a jpeg huffman value from the bitstream +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +{ + unsigned int temp; + int c,k; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k=FAST_BITS+1 ; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<<n) + 1 +static int const stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767}; + +// combined JPEG 'receive' and JPEG 'extend', since baseline +// always extends everything it receives. +stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n) +{ + unsigned int k; + int sgn; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + + sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB + k = stbi_lrot(j->code_buffer, n); + STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & ~sgn); +} + +// get some unsigned bits +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +{ + unsigned int k; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) +{ + unsigned int k; + if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static stbi_uc stbi__jpeg_dezigzag[64+15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi_uc *dequant) +{ + int diff,dc,k; + int t; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data,0,64*sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +{ + int diff,dc; + int t; + if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + diff = t ? stbi__extend_receive(j, t) : 0; + + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc << j->succ_low); + } else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short) (1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) +{ + int k; + if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) << shift); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) << shift); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short) (1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } else { + k = j->spec_start; + do { + int r,s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short) s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +stbi_inline static stbi_uc stbi__clamp(int x) +{ + // trick to use a single test to catch both cases + if ((unsigned int) x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (stbi_uc) x; +} + +#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) << 12) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3*stbi__f2f(-1.847759065f); \ + t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2+p3); \ + t1 = stbi__fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ + t0 = t0*stbi__f2f( 0.298631336f); \ + t1 = t1*stbi__f2f( 2.053119869f); \ + t2 = t2*stbi__f2f( 3.072711026f); \ + t3 = t3*stbi__f2f( 1.501321110f); \ + p1 = p5 + p1*stbi__f2f(-0.899976223f); \ + p2 = p5 + p2*stbi__f2f(-2.562915447f); \ + p3 = p3*stbi__f2f(-1.961570560f); \ + p4 = p4*stbi__f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) +{ + int i,val[64],*v=val; + stbi_uc *o; + short *d = data; + + // columns + for (i=0; i < 8; ++i,++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 + && d[40]==0 && d[48]==0 && d[56]==0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] << 2; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[ 0] = (x0+t3) >> 10; + v[56] = (x0-t3) >> 10; + v[ 8] = (x1+t2) >> 10; + v[48] = (x1-t2) >> 10; + v[16] = (x2+t1) >> 10; + v[40] = (x2-t1) >> 10; + v[24] = (x3+t0) >> 10; + v[32] = (x3-t0) >> 10; + } + } + + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128<<17); + x1 += 65536 + (128<<17); + x2 += 65536 + (128<<17); + x3 += 65536 + (128<<17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0+t3) >> 17); + o[7] = stbi__clamp((x0-t3) >> 17); + o[1] = stbi__clamp((x1+t2) >> 17); + o[6] = stbi__clamp((x1-t2) >> 17); + o[2] = stbi__clamp((x2+t1) >> 17); + o[5] = stbi__clamp((x2-t1) >> 17); + o[3] = stbi__clamp((x3+t0) >> 17); + o[4] = stbi__clamp((x3-t0) >> 17); + } +} + +#ifdef STBI_SSE2 +// sse2 integer IDCT. not the fastest possible implementation but it +// produces bit-identical results to the generic C version so it's +// fully "transparent". +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + + // dot product constant: even elems=x, odd elems=y + #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) + + // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) + // out(1) = c1[even]*x + c1[odd]*y + #define dct_rot(out0,out1, x,y,c0,c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + + // out = in << 12 (in 16-bit, out 32-bit) + #define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + + // wide add + #define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + + // wide sub + #define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + + // butterfly a/b, add bias, then shift by "s" and pack + #define dct_bfly32o(out0, out1, a,b,bias,s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + + // 8-bit interleave step (for transposes) + #define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + + // 16-bit interleave step (for transposes) + #define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + + #define dct_pass(bias,shift) \ + { \ + /* even part */ \ + dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ + dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0,row7, x0,x7,bias,shift); \ + dct_bfly32o(row1,row6, x1,x6,bias,shift); \ + dct_bfly32o(row2,row5, x2,x5,bias,shift); \ + dct_bfly32o(row3,row4, x3,x4,bias,shift); \ + } + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); + + // load + row0 = _mm_load_si128((const __m128i *) (data + 0*8)); + row1 = _mm_load_si128((const __m128i *) (data + 1*8)); + row2 = _mm_load_si128((const __m128i *) (data + 2*8)); + row3 = _mm_load_si128((const __m128i *) (data + 3*8)); + row4 = _mm_load_si128((const __m128i *) (data + 4*8)); + row5 = _mm_load_si128((const __m128i *) (data + 5*8)); + row6 = _mm_load_si128((const __m128i *) (data + 6*8)); + row7 = _mm_load_si128((const __m128i *) (data + 7*8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *) out, p0); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p2); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p1); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p3); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif // STBI_SSE2 + +#ifdef STBI_NEON + +// NEON integer IDCT. should produce bit-identical +// results to the generic C version. +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + +// wide add +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + +// wide sub +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + +// butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ + dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ + dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ + dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ + } + + // load + row0 = vld1q_s16(data + 0*8); + row1 = vld1q_s16(data + 1*8); + row2 = vld1q_s16(data + 2*8); + row3 = vld1q_s16(data + 3*8); + row4 = vld1q_s16(data + 4*8); + row5 = vld1q_s16(data + 5*8); + row6 = vld1q_s16(data + 6*8); + row7 = vld1q_s16(data + 7*8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { +// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. +// whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } +#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } +#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); out += out_stride; + vst1_u8(out, p1); out += out_stride; + vst1_u8(out, p2); out += out_stride; + vst1_u8(out, p3); out += out_stride; + vst1_u8(out, p4); out += out_stride; + vst1_u8(out, p5); out += out_stride; + vst1_u8(out, p6); out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif // STBI_NEON + +#define STBI__MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static stbi_uc stbi__get_marker(stbi__jpeg *j) +{ + stbi_uc x; + if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } + x = stbi__get8(j->s); + if (x != 0xff) return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, stbi__jpeg_reset the entropy decoder and +// the dc prediction +static void stbi__jpeg_reset(stbi__jpeg *j) +{ + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +{ + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i,j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + STBI_SIMD_ALIGN(short, data[64]); + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x)*8; + int y2 = (j*z->img_comp[n].v + y)*8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } else { + if (z->scan_n == 1) { + int i,j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x); + int y2 = (j*z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi_uc *dequant) +{ + int i; + for (i=0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) +{ + if (z->progressive) { + // dequantize and idct the data + int i,j,n; + for (n=0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + } + } + } + } +} + +static int stbi__process_marker(stbi__jpeg *z, int m) +{ + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker","Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s)-2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4; + int t = q & 15,i; + if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG"); + if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); + for (i=0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); + L -= 65; + } + return L==0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s)-2; + while (L > 0) { + stbi_uc *v; + int sizes[16],i,n=0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); + for (i=0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; + v = z->huff_dc[th].values; + } else { + if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; + v = z->huff_ac[th].values; + } + for (i=0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L==0; + } + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + stbi__skip(z->s, stbi__get16be(z->s)-2); + return 1; + } + return 0; +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) +{ + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); + if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); + for (i=0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) return 0; // no match + z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); + z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) +{ + stbi__context *s = z->s; + int Lf,p,i,q, h_max=1,v_max=1,c; + Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG + p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires + c = stbi__get8(s); + if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG"); // JFIF requires + s->img_n = c; + for (i=0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); + + for (i=0; i < s->img_n; ++i) { + z->img_comp[i].id = stbi__get8(s); + if (z->img_comp[i].id != i+1) // JFIF requires + if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! + return stbi__err("bad component ID","Corrupt JPEG"); + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) return 1; + + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + + for (i=0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; + + for (i=0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].raw_data = stbi__malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); + + if (z->img_comp[i].raw_data == NULL) { + for(--i; i >= 0; --i) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; + } + return stbi__err("outofmem", "Out of memory"); + } + // align blocks for idct using mmx/sse + z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); + z->img_comp[i].linebuf = NULL; + if (z->progressive) { + z->img_comp[i].coeff_w = (z->img_comp[i].w2 + 7) >> 3; + z->img_comp[i].coeff_h = (z->img_comp[i].h2 + 7) >> 3; + z->img_comp[i].raw_coeff = STBI_MALLOC(z->img_comp[i].coeff_w * z->img_comp[i].coeff_h * 64 * sizeof(short) + 15); + z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); + } else { + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +{ + int m; + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); + if (scan == STBI__SCAN_type) return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z,m)) return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) return 0; + return 1; +} + +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) +{ + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) return 0; + if (!stbi__parse_entropy_coded_data(j)) return 0; + if (j->marker == STBI__MARKER_none ) { + // handle 0s at the end of image data from IP Kamera 9060 + while (!stbi__at_eof(j->s)) { + int x = stbi__get8(j->s); + if (x == 255) { + j->marker = stbi__get8(j->s); + break; + } else if (x != 0) { + return stbi__err("junk before marker", "Corrupt JPEG"); + } + } + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + } + } else { + if (!stbi__process_marker(j, m)) return 0; + } + m = stbi__get_marker(j); + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, + int w, int hs); + +#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i=0; i < w; ++i) + out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0]*3 + input[1] + 2); + for (i=1; i < w-1; ++i) { + int n = 3*input[i]+2; + out[i*2+0] = stbi__div4(n+input[i-1]); + out[i*2+1] = stbi__div4(n+input[i+1]); + } + out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); + out[i*2+1] = input[w-1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i,t0,t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + out[0] = stbi__div4(t1+2); + for (i=1; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i=0,t0,t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w-1) & ~7); i += 8) { +#if defined(STBI_SSE2) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *) (out + i*2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i*2, o); +#endif + + // "previous" value for next iter + t1 = 3*in_near[i+7] + in_far[i+7]; + } + + t0 = t1; + t1 = 3*in_near[i] + in_far[i]; + out[i*2] = stbi__div16(3*t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // resample with nearest-neighbor + int i,j; + STBI_NOTUSED(in_far); + for (i=0; i < w; ++i) + for (j=0; j < hs; ++j) + out[i*hs+j] = in_near[i]; + return out; +} + +#ifdef STBI_JPEG_OLD +// this is the same YCbCr-to-RGB calculation that stb_image has used +// historically before the algorithm changes in 1.49 +#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 16) + 32768; // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr*float2fixed(1.40200f); + g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); + b = y_fixed + cb*float2fixed(1.77200f); + r >>= 16; + g >>= 16; + b >>= 16; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#else +// this is a reduced-precision calculation of YCbCr-to-RGB introduced +// to make sure the code produces the same results in both SIMD and scalar +#define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* float2fixed(1.40200f); + g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) +{ + int i = 0; + +#ifdef STBI_SSE2 + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); + __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); + __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); + __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); + __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i+7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *) (out + 0), o0); + _mm_storeu_si128((__m128i *) (out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); + int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); + int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); + int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); + + for (; i+7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8*4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* float2fixed(1.40200f); + g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +// set up the kernels +static void stbi__setup_jpeg(stbi__jpeg *j) +{ + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + #ifndef STBI_JPEG_OLD + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + #endif + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + j->idct_block_kernel = stbi__idct_simd; + #ifndef STBI_JPEG_OLD + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + #endif + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; +#endif +} + +// clean up the temporary component buffers +static void stbi__cleanup_jpeg(stbi__jpeg *j) +{ + int i; + for (i=0; i < j->s->img_n; ++i) { + if (j->img_comp[i].raw_data) { + STBI_FREE(j->img_comp[i].raw_data); + j->img_comp[i].raw_data = NULL; + j->img_comp[i].data = NULL; + } + if (j->img_comp[i].raw_coeff) { + STBI_FREE(j->img_comp[i].raw_coeff); + j->img_comp[i].raw_coeff = 0; + j->img_comp[i].coeff = 0; + } + if (j->img_comp[i].linebuf) { + STBI_FREE(j->img_comp[i].linebuf); + j->img_comp[i].linebuf = NULL; + } + } +} + +typedef struct +{ + resample_row_func resample; + stbi_uc *line0,*line1; + int hs,vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +{ + int n, decode_n; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n; + + if (z->s->img_n == 3 && n < 3) + decode_n = 1; + else + decode_n = z->s->img_n; + + // resample and color-convert + { + int k; + unsigned int i,j; + stbi_uc *output; + stbi_uc *coutput[4]; + + stbi__resample res_comp[4]; + + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs-1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; + else r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *) stbi__malloc(n * z->s->img_x * z->s->img_y + 1); + if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + // now go ahead and resample + for (j=0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } else + for (i=0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) *comp = z->s->img_n; // report original components, not output + return output; + } +} + +static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__jpeg j; + j.s = s; + stbi__setup_jpeg(&j); + return load_jpeg_image(&j, x,y,comp,req_comp); +} + +static int stbi__jpeg_test(stbi__context *s) +{ + int r; + stbi__jpeg j; + j.s = s; + stbi__setup_jpeg(&j); + r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); + stbi__rewind(s); + return r; +} + +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) +{ + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind( j->s ); + return 0; + } + if (x) *x = j->s->img_x; + if (y) *y = j->s->img_y; + if (comp) *comp = j->s->img_n; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__jpeg j; + j.s = s; + return stbi__jpeg_info_raw(&j, x, y, comp); +} +#endif + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +#ifndef STBI_NO_ZLIB + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct +{ + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[288]; + stbi__uint16 value[288]; +} stbi__zhuffman; + +stbi_inline static int stbi__bitreverse16(int n) +{ + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +stbi_inline static int stbi__bit_reverse(int v, int bits) +{ + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16-bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num) +{ + int i,k=0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i=0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i=1; i < 16; ++i) + if (sizes[i] > (1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i=1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16) code; + z->firstsymbol[i] = (stbi__uint16) k; + code = (code + sizes[i]); + if (sizes[i]) + if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); + z->maxcode[i] = code << (16-i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i=0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); + z->size [c] = (stbi_uc ) s; + z->value[c] = (stbi__uint16) i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s],s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +typedef struct +{ + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + stbi__uint32 code_buffer; + + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; + + stbi__zhuffman z_length, z_distance; +} stbi__zbuf; + +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) +{ + if (z->zbuffer >= z->zbuffer_end) return 0; + return *z->zbuffer++; +} + +static void stbi__fill_bits(stbi__zbuf *z) +{ + do { + STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); + z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) +{ + unsigned int k; + if (z->num_bits < n) stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s,k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s=STBI__ZFAST_BITS+1; ; ++s) + if (k < z->maxcode[s]) + break; + if (s == 16) return -1; // invalid code! + // code size is s, so: + b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; + STBI_ASSERT(z->size[b] == s); + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s; + if (a->num_bits < 16) stbi__fill_bits(a); + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +{ + char *q; + int cur, limit; + z->zout = zout; + if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); + cur = (int) (z->zout - z->zout_start); + limit = (int) (z->zout_end - z->zout_start); + while (cur + n > limit) + limit *= 2; + q = (char *) STBI_REALLOC(z->zout_start, limit); + if (q == NULL) return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; +} + +static int stbi__zlength_base[31] = { + 3,4,5,6,7,8,9,10,11,13, + 15,17,19,23,27,31,35,43,51,59, + 67,83,99,115,131,163,195,227,258,0,0 }; + +static int stbi__zlength_extra[31]= +{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + +static int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, +257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + +static int stbi__zdist_extra[32] = +{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +static int stbi__parse_huffman_block(stbi__zbuf *a) +{ + char *zout = a->zout; + for(;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) return 0; + zout = a->zout; + } + *zout++ = (char) z; + } else { + stbi_uc *p; + int len,dist; + if (z == 256) { + a->zout = zout; + return 1; + } + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); + if (zout + len > a->zout_end) { + if (!stbi__zexpand(a, zout, len)) return 0; + zout = a->zout; + } + p = (stbi_uc *) (zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { do *zout++ = v; while (--len); } + } else { + if (len) { do *zout++ = *p++; while (--len); } + } + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) +{ + static stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286+32+137];//padding for maximum single op + stbi_uc codelength_sizes[19]; + int i,n; + + int hlit = stbi__zreceive(a,5) + 257; + int hdist = stbi__zreceive(a,5) + 1; + int hclen = stbi__zreceive(a,4) + 4; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i=0; i < hclen; ++i) { + int s = stbi__zreceive(a,3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; + + n = 0; + while (n < hlit + hdist) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc) c; + else if (c == 16) { + c = stbi__zreceive(a,2)+3; + memset(lencodes+n, lencodes[n-1], c); + n += c; + } else if (c == 17) { + c = stbi__zreceive(a,3)+3; + memset(lencodes+n, 0, c); + n += c; + } else { + STBI_ASSERT(c == 18); + c = stbi__zreceive(a,7)+11; + memset(lencodes+n, 0, c); + n += c; + } + } + if (n != hlit+hdist) return stbi__err("bad codelengths","Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; + return 1; +} + +static int stbi__parse_uncomperssed_block(stbi__zbuf *a) +{ + stbi_uc header[4]; + int len,nlen,k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + STBI_ASSERT(a->num_bits == 0); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) +{ + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec + if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +// @TODO: should statically initialize these for optimal thread safety +static stbi_uc stbi__zdefault_length[288], stbi__zdefault_distance[32]; +static void stbi__init_zdefaults(void) +{ + int i; // use <= to match clearly with spec + for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; + for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; + for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; + for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; + + for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; +} + +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) +{ + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) return 0; + a->num_bits = 0; + a->code_buffer = 0; + do { + final = stbi__zreceive(a,1); + type = stbi__zreceive(a,2); + if (type == 0) { + if (!stbi__parse_uncomperssed_block(a)) return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zdefault_distance[31]) stbi__init_zdefaults(); + if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; + } else { + if (!stbi__compute_huffman_codes(a)) return 0; + } + if (!stbi__parse_huffman_block(a)) return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) +{ + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) +{ + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int) (a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(16384); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer+len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int) (a.zout - a.zout_start); + else + return -1; +} +#endif + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + +#ifndef STBI_NO_PNG +typedef struct +{ + stbi__uint32 length; + stbi__uint32 type; +} stbi__pngchunk; + +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) +{ + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; +} + +static int stbi__check_png_header(stbi__context *s) +{ + static stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; + int i; + for (i=0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); + return 1; +} + +typedef struct +{ + stbi__context *s; + stbi_uc *idata, *expanded, *out; +} stbi__png; + + +enum { + STBI__F_none=0, + STBI__F_sub=1, + STBI__F_up=2, + STBI__F_avg=3, + STBI__F_paeth=4, + // synthetic filters used for first scanline to avoid needing a dummy row of 0s + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static stbi_uc first_row_filter[5] = +{ + STBI__F_none, + STBI__F_sub, + STBI__F_none, + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static int stbi__paeth(int a, int b, int c) +{ + int p = a + b - c; + int pa = abs(p-a); + int pb = abs(p-b); + int pc = abs(p-c); + if (pa <= pb && pa <= pc) return a; + if (pb <= pc) return b; + return c; +} + +static stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; + +// create the png data from post-deflated data +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) +{ + stbi__context *s = a->s; + stbi__uint32 i,j,stride = x*out_n; + stbi__uint32 img_len, img_width_bytes; + int k; + int img_n = s->img_n; // copy it into a local for later + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); + a->out = (stbi_uc *) stbi__malloc(x * y * out_n); // extra bytes to write off the end into + if (!a->out) return stbi__err("outofmem", "Out of memory"); + + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + img_len = (img_width_bytes + 1) * y; + if (s->img_x == x && s->img_y == y) { + if (raw_len != img_len) return stbi__err("not enough pixels","Corrupt PNG"); + } else { // interlaced: + if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); + } + + for (j=0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *prior = cur - stride; + int filter = *raw++; + int filter_bytes = img_n; + int width = x; + if (filter > 4) + return stbi__err("invalid filter","Corrupt PNG"); + + if (depth < 8) { + STBI_ASSERT(img_width_bytes <= x); + cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place + filter_bytes = 1; + width = img_width_bytes; + } + + // if first row, use special filter that doesn't sample previous row + if (j == 0) filter = first_row_filter[filter]; + + // handle first byte explicitly + for (k=0; k < filter_bytes; ++k) { + switch (filter) { + case STBI__F_none : cur[k] = raw[k]; break; + case STBI__F_sub : cur[k] = raw[k]; break; + case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; + case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; + case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; + case STBI__F_avg_first : cur[k] = raw[k]; break; + case STBI__F_paeth_first: cur[k] = raw[k]; break; + } + } + + if (depth == 8) { + if (img_n != out_n) + cur[img_n] = 255; // first pixel + raw += img_n; + cur += out_n; + prior += out_n; + } else { + raw += 1; + cur += 1; + prior += 1; + } + + // this is a little gross, so that we don't switch per-pixel or per-component + if (depth < 8 || img_n == out_n) { + int nk = (width - 1)*img_n; + #define CASE(f) \ + case f: \ + for (k=0; k < nk; ++k) + switch (filter) { + // "none" filter turns into a memcpy here; make that explicit. + case STBI__F_none: memcpy(cur, raw, nk); break; + CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break; + CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; + CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break; + CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break; + CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break; + CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break; + } + #undef CASE + raw += nk; + } else { + STBI_ASSERT(img_n+1 == out_n); + #define CASE(f) \ + case f: \ + for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ + for (k=0; k < img_n; ++k) + switch (filter) { + CASE(STBI__F_none) cur[k] = raw[k]; break; + CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-out_n]); break; + CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; + CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-out_n])>>1)); break; + CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; + CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-out_n] >> 1)); break; + CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],0,0)); break; + } + #undef CASE + } + } + + // we make a separate pass to expand bits to pixels; for performance, + // this could run two scanlines behind the above code, so it won't + // intefere with filtering but will still be in the cache. + if (depth < 8) { + for (j=0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; + // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit + // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop + stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range + + // note that the final byte might overshoot and write more data than desired. + // we can allocate enough data that this never writes out of memory, but it + // could also overwrite the next scanline. can it overwrite non-empty data + // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. + // so we need to explicitly clamp the final ones + + if (depth == 4) { + for (k=x*img_n; k >= 2; k-=2, ++in) { + *cur++ = scale * ((*in >> 4) ); + *cur++ = scale * ((*in ) & 0x0f); + } + if (k > 0) *cur++ = scale * ((*in >> 4) ); + } else if (depth == 2) { + for (k=x*img_n; k >= 4; k-=4, ++in) { + *cur++ = scale * ((*in >> 6) ); + *cur++ = scale * ((*in >> 4) & 0x03); + *cur++ = scale * ((*in >> 2) & 0x03); + *cur++ = scale * ((*in ) & 0x03); + } + if (k > 0) *cur++ = scale * ((*in >> 6) ); + if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); + if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); + } else if (depth == 1) { + for (k=x*img_n; k >= 8; k-=8, ++in) { + *cur++ = scale * ((*in >> 7) ); + *cur++ = scale * ((*in >> 6) & 0x01); + *cur++ = scale * ((*in >> 5) & 0x01); + *cur++ = scale * ((*in >> 4) & 0x01); + *cur++ = scale * ((*in >> 3) & 0x01); + *cur++ = scale * ((*in >> 2) & 0x01); + *cur++ = scale * ((*in >> 1) & 0x01); + *cur++ = scale * ((*in ) & 0x01); + } + if (k > 0) *cur++ = scale * ((*in >> 7) ); + if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); + if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); + if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); + if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); + if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); + if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); + } + if (img_n != out_n) { + int q; + // insert alpha = 255 + cur = a->out + stride*j; + if (img_n == 1) { + for (q=x-1; q >= 0; --q) { + cur[q*2+1] = 255; + cur[q*2+0] = cur[q]; + } + } else { + STBI_ASSERT(img_n == 3); + for (q=x-1; q >= 0; --q) { + cur[q*4+3] = 255; + cur[q*4+2] = cur[q*3+2]; + cur[q*4+1] = cur[q*3+1]; + cur[q*4+0] = cur[q*3+0]; + } + } + } + } + } + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) +{ + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *) stbi__malloc(a->s->img_x * a->s->img_y * out_n); + for (p=0; p < 7; ++p) { + int xorig[] = { 0,4,0,2,0,1,0 }; + int yorig[] = { 0,0,4,0,2,0,1 }; + int xspc[] = { 8,8,4,4,2,2,1 }; + int yspc[] = { 8,8,8,4,4,2,2 }; + int i,j,x,y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { + STBI_FREE(final); + return 0; + } + for (j=0; j < y; ++j) { + for (i=0; i < x; ++i) { + int out_y = j*yspc[p]+yorig[p]; + int out_x = i*xspc[p]+xorig[p]; + memcpy(final + out_y*a->s->img_x*out_n + out_x*out_n, + a->out + (j*x+i)*out_n, out_n); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; + + return 1; +} + +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i=0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i=0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) +{ + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *) stbi__malloc(pixel_count * pal_img_n); + if (p == NULL) return stbi__err("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p += 3; + } + } else { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p[3] = palette[n+3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; + + STBI_NOTUSED(len); + + return 1; +} + +static int stbi__unpremultiply_on_load = 0; +static int stbi__de_iphone_flag = 0; + +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) +{ + stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) +{ + stbi__de_iphone_flag = flag_true_if_should_convert; +} + +static void stbi__de_iphone(stbi__png *z) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i=0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + p[0] = p[2] * 255 / a; + p[1] = p[1] * 255 / a; + p[2] = t * 255 / a; + } else { + p[0] = p[2]; + p[2] = t; + } + p += 4; + } + } else { + // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) +{ + stbi_uc palette[1024], pal_img_n=0; + stbi_uc has_trans=0, tc[3]; + stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; + int first=1,k,interlace=0, color=0, depth=0, is_iphone=0; + stbi__context *s = z->s; + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) return 0; + + if (scan == STBI__SCAN_type) return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C','g','B','I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I','H','D','R'): { + int comp,filter; + if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); + first = 0; + if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); + s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); + s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); + depth = stbi__get8(s); if (depth != 1 && depth != 2 && depth != 4 && depth != 8) return stbi__err("1/2/4/8-bit only","PNG not supported: 1/2/4/8-bit only"); + color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); + if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); + comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); + filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); + interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); + if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + if (scan == STBI__SCAN_header) return 1; + } else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); + // if SCAN_header, have to scan to see if we have a tRNS + } + break; + } + + case STBI__PNG_TYPE('P','L','T','E'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); + for (i=0; i < pal_len; ++i) { + palette[i*4+0] = stbi__get8(s); + palette[i*4+1] = stbi__get8(s); + palette[i*4+2] = stbi__get8(s); + palette[i*4+3] = 255; + } + break; + } + + case STBI__PNG_TYPE('t','R','N','S'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } + if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); + if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); + pal_img_n = 4; + for (i=0; i < c.length; ++i) + palette[i*4+3] = stbi__get8(s); + } else { + if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); + if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); + has_trans = 1; + for (k=0; k < s->img_n; ++k) + tc[k] = (stbi_uc) (stbi__get16be(s) & 255) * stbi__depth_scale_table[depth]; // non 8-bit images will be larger + } + break; + } + + case STBI__PNG_TYPE('I','D','A','T'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); + if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } + if ((int)(ioff + c.length) < (int)ioff) return 0; + if (ioff + c.length > idata_limit) { + stbi_uc *p; + if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + p = (stbi_uc *) STBI_REALLOC(z->idata, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); + ioff += c.length; + break; + } + + case STBI__PNG_TYPE('I','E','N','D'): { + stbi__uint32 raw_len, bpl; + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) return 1; + if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); + if (z->expanded == NULL) return 0; // zlib should set error + STBI_FREE(z->idata); z->idata = NULL; + if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) + s->img_out_n = s->img_n+1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, depth, color, interlace)) return 0; + if (has_trans) + if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) s->img_out_n = req_comp; + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } + STBI_FREE(z->expanded); z->expanded = NULL; + return 1; + } + + default: + // if critical, fail + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { + #ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); + #endif + return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static unsigned char *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp) +{ + unsigned char *result=NULL; + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + result = stbi__convert_format(result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) *n = p->s->img_out_n; + } + STBI_FREE(p->out); p->out = NULL; + STBI_FREE(p->expanded); p->expanded = NULL; + STBI_FREE(p->idata); p->idata = NULL; + + return result; +} + +static unsigned char *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__png p; + p.s = s; + return stbi__do_png(&p, x,y,comp,req_comp); +} + +static int stbi__png_test(stbi__context *s) +{ + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) +{ + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind( p->s ); + return 0; + } + if (x) *x = p->s->img_x; + if (y) *y = p->s->img_y; + if (comp) *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} +#endif + +// Microsoft/Windows BMP image + +#ifndef STBI_NO_BMP +static int stbi__bmp_test_raw(stbi__context *s) +{ + int r; + int sz; + if (stbi__get8(s) != 'B') return 0; + if (stbi__get8(s) != 'M') return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) +{ + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; +} + + +// returns 0..31 for the highest set bit +static int stbi__high_bit(unsigned int z) +{ + int n=0; + if (z == 0) return -1; + if (z >= 0x10000) n += 16, z >>= 16; + if (z >= 0x00100) n += 8, z >>= 8; + if (z >= 0x00010) n += 4, z >>= 4; + if (z >= 0x00004) n += 2, z >>= 2; + if (z >= 0x00002) n += 1, z >>= 1; + return n; +} + +static int stbi__bitcount(unsigned int a) +{ + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +static int stbi__shiftsigned(int v, int shift, int bits) +{ + int result; + int z=0; + + if (shift < 0) v <<= -shift; + else v >>= shift; + result = v; + + z = bits; + while (z < 8) { + result += v >> z; + z += bits; + } + return result; +} + +static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *out; + unsigned int mr=0,mg=0,mb=0,ma=0, all_a=255; + stbi_uc pal[256][4]; + int psize=0,i,j,compress=0,width; + int bpp, flip_vertically, pad, target, offset, hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + offset = stbi__get32le(s); + hsz = stbi__get32le(s); + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); + bpp = stbi__get16le(s); + if (bpp == 1) return stbi__errpuc("monochrome", "BMP type not supported: 1-bit"); + flip_vertically = ((int) s->img_y) > 0; + s->img_y = abs((int) s->img_y); + if (hsz == 12) { + if (bpp < 24) + psize = (offset - 14 - 24) / 3; + } else { + compress = stbi__get32le(s); + if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (bpp == 16 || bpp == 32) { + mr = mg = mb = 0; + if (compress == 0) { + if (bpp == 32) { + mr = 0xffu << 16; + mg = 0xffu << 8; + mb = 0xffu << 0; + ma = 0xffu << 24; + all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 + } else { + mr = 31u << 10; + mg = 31u << 5; + mb = 31u << 0; + } + } else if (compress == 3) { + mr = stbi__get32le(s); + mg = stbi__get32le(s); + mb = stbi__get32le(s); + // not documented, but generated by photoshop and handled by mspaint + if (mr == mg && mg == mb) { + // ?!?!? + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else { + STBI_ASSERT(hsz == 108 || hsz == 124); + mr = stbi__get32le(s); + mg = stbi__get32le(s); + mb = stbi__get32le(s); + ma = stbi__get32le(s); + stbi__get32le(s); // discard color space + for (i=0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved + } + } + if (bpp < 16) + psize = (offset - 14 - hsz) >> 2; + } + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + out = (stbi_uc *) stbi__malloc(target * s->img_x * s->img_y); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + if (bpp < 16) { + int z=0; + if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } + for (i=0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (hsz != 12) stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, offset - 14 - hsz - psize * (hsz == 12 ? 3 : 4)); + if (bpp == 4) width = (s->img_x + 1) >> 1; + else if (bpp == 8) width = s->img_x; + else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } + pad = (-width)&3; + for (j=0; j < (int) s->img_y; ++j) { + for (i=0; i < (int) s->img_x; i += 2) { + int v=stbi__get8(s),v2=0; + if (bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) s->img_x) break; + v = (bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + } + stbi__skip(s, pad); + } + } else { + int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; + int z = 0; + int easy=0; + stbi__skip(s, offset - 14 - hsz); + if (bpp == 24) width = 3 * s->img_x; + else if (bpp == 16) width = 2*s->img_x; + else /* bpp = 32 and pad = 0 */ width=0; + pad = (-width) & 3; + if (bpp == 24) { + easy = 1; + } else if (bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); + } + for (j=0; j < (int) s->img_y; ++j) { + if (easy) { + for (i=0; i < (int) s->img_x; ++i) { + unsigned char a; + out[z+2] = stbi__get8(s); + out[z+1] = stbi__get8(s); + out[z+0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) out[z++] = a; + } + } else { + for (i=0; i < (int) s->img_x; ++i) { + stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); + int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) out[z++] = STBI__BYTECAST(a); + } + } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j=0; j < (int) s->img_y>>1; ++j) { + stbi_uc *p1 = out + j *s->img_x*target; + stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; + for (i=0; i < (int) s->img_x*target; ++i) { + t = p1[i], p1[i] = p2[i], p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + return out; +} +#endif + +// Targa Truevision - TGA +// by Jonathan Dummer +#ifndef STBI_NO_TGA +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) +{ + int tga_w, tga_h, tga_comp; + int sz; + stbi__get8(s); // discard Offset + sz = stbi__get8(s); // color type + if( sz > 1 ) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + sz = stbi__get8(s); // image type + // only RGB or grey allowed, +/- RLE + if ((sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11)) return 0; + stbi__skip(s,9); + tga_w = stbi__get16le(s); + if( tga_w < 1 ) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if( tga_h < 1 ) { + stbi__rewind(s); + return 0; // test height + } + sz = stbi__get8(s); // bits per pixel + // only RGB or RGBA or grey allowed + if ((sz != 8) && (sz != 16) && (sz != 24) && (sz != 32)) { + stbi__rewind(s); + return 0; + } + tga_comp = sz; + if (x) *x = tga_w; + if (y) *y = tga_h; + if (comp) *comp = tga_comp / 8; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) +{ + int res; + int sz; + stbi__get8(s); // discard Offset + sz = stbi__get8(s); // color type + if ( sz > 1 ) return 0; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if ( (sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11) ) return 0; // only RGB or grey allowed, +/- RLE + stbi__get16be(s); // discard palette start + stbi__get16be(s); // discard palette length + stbi__get8(s); // discard bits per palette color entry + stbi__get16be(s); // discard x origin + stbi__get16be(s); // discard y origin + if ( stbi__get16be(s) < 1 ) return 0; // test width + if ( stbi__get16be(s) < 1 ) return 0; // test height + sz = stbi__get8(s); // bits per pixel + if ( (sz != 8) && (sz != 16) && (sz != 24) && (sz != 32) ) + res = 0; + else + res = 1; + stbi__rewind(s); + return res; +} + +static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp = tga_bits_per_pixel / 8; + int tga_inverted = stbi__get8(s); + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4]; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + + // do a tiny bit of precessing + if ( tga_image_type >= 8 ) + { + tga_image_type -= 8; + tga_is_RLE = 1; + } + /* int tga_alpha_bits = tga_inverted & 15; */ + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // error check + if ( //(tga_indexed) || + (tga_width < 1) || (tga_height < 1) || + (tga_image_type < 1) || (tga_image_type > 3) || + ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && + (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) + ) + { + return NULL; // we don't report this as a bad TGA because we don't even know if it's TGA + } + + // If I'm paletted, then I'll use the number of bits from the palette + if ( tga_indexed ) + { + tga_comp = tga_palette_bits / 8; + } + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) *comp = tga_comp; + + tga_data = (unsigned char*)stbi__malloc( (size_t)tga_width * tga_height * tga_comp ); + if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset ); + + if ( !tga_indexed && !tga_is_RLE) { + for (i=0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height -i - 1 : i; + stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } else { + // do I need to load a palette? + if ( tga_indexed) + { + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start ); + // load the palette + tga_palette = (unsigned char*)stbi__malloc( tga_palette_len * tga_palette_bits / 8 ); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); + } + if (!stbi__getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) { + STBI_FREE(tga_data); + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + } + // load the data + for (i=0; i < tga_width * tga_height; ++i) + { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if ( tga_is_RLE ) + { + if ( RLE_count == 0 ) + { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if ( !RLE_repeating ) + { + read_next_pixel = 1; + } + } else + { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if ( read_next_pixel ) + { + // load however much data we did have + if ( tga_indexed ) + { + // read in 1 byte, then perform the lookup + int pal_idx = stbi__get8(s); + if ( pal_idx >= tga_palette_len ) + { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_bits_per_pixel / 8; + for (j = 0; j*8 < tga_bits_per_pixel; ++j) + { + raw_data[j] = tga_palette[pal_idx+j]; + } + } else + { + // read in the data raw + for (j = 0; j*8 < tga_bits_per_pixel; ++j) + { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i*tga_comp+j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if ( tga_inverted ) + { + for (j = 0; j*2 < tga_height; ++j) + { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if ( tga_palette != NULL ) + { + STBI_FREE( tga_palette ); + } + } + + // swap RGB + if (tga_comp >= 3) + { + unsigned char* tga_pixel = tga_data; + for (i=0; i < tga_width * tga_height; ++i) + { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + // OK, done + return tga_data; +} +#endif + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s) +{ + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + int pixelCount; + int channelCount, compression; + int channel, i, count, len; + int bitdepth; + int w,h; + stbi_uc *out; + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6 ); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + stbi__skip(s,stbi__get32be(s) ); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s) ); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s) ); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", "PSD has an unknown compression format"); + + // Create the destination image. + out = (stbi_uc *) stbi__malloc(4 * w*h); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w*h; + + // Initialize the data to zero. + //memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, + // which we're going to just skip. + stbi__skip(s, h * channelCount * 2 ); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out+channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } else { + // Read the RLE data. + count = 0; + while (count < pixelCount) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; + } + } else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len ^= 0x0FF; + len += 2; + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + } + } + + } else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out + channel; + if (channel >= channelCount) { + // Fill this channel with default data. + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } else { + // Read the data. + if (bitdepth == 16) { + for (i = 0; i < pixelCount; i++, p += 4) + *p = (stbi_uc) (stbi__get16be(s) >> 8); + } else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } + } + } + + if (req_comp && req_comp != 4) { + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + if (comp) *comp = 4; + *y = h; + *x = w; + + return out; +} +#endif + +// ************************************************************************************************* +// Softimage PIC loader +// by Tom Seddon +// +// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format +// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ + +#ifndef STBI_NO_PIC +static int stbi__pic_is4(stbi__context *s,const char *str) +{ + int i; + for (i=0; i<4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; + + return 1; +} + +static int stbi__pic_test_core(stbi__context *s) +{ + int i; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) + return 0; + + for(i=0;i<84;++i) + stbi__get8(s); + + if (!stbi__pic_is4(s,"PICT")) + return 0; + + return 1; +} + +typedef struct +{ + stbi_uc size,type,channel; +} stbi__pic_packet; + +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) +{ + int mask=0x80, i; + + for (i=0; i<4; ++i, mask>>=1) { + if (channel & mask) { + if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); + dest[i]=stbi__get8(s); + } + } + + return dest; +} + +static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) +{ + int mask=0x80,i; + + for (i=0;i<4; ++i, mask>>=1) + if (channel&mask) + dest[i]=src[i]; +} + +static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) +{ + int act_comp=0,num_packets=0,y,chained; + stbi__pic_packet packets[10]; + + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return stbi__errpuc("bad format","too many packets"); + + packet = &packets[num_packets++]; + + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + + act_comp |= packet->channel; + + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); + if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + + for(y=0; y<height; ++y) { + int packet_idx; + + for(packet_idx=0; packet_idx < num_packets; ++packet_idx) { + stbi__pic_packet *packet = &packets[packet_idx]; + stbi_uc *dest = result+y*width*4; + + switch (packet->type) { + default: + return stbi__errpuc("bad format","packet has bad compression type"); + + case 0: {//uncompressed + int x; + + for(x=0;x<width;++x, dest+=4) + if (!stbi__readval(s,packet->channel,dest)) + return 0; + break; + } + + case 1://Pure RLE + { + int left=width, i; + + while (left>0) { + stbi_uc count,value[4]; + + count=stbi__get8(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); + + if (count > left) + count = (stbi_uc) left; + + if (!stbi__readval(s,packet->channel,value)) return 0; + + for(i=0; i<count; ++i,dest+=4) + stbi__copyval(packet->channel,dest,value); + left -= count; + } + } + break; + + case 2: {//Mixed RLE + int left=width; + while (left>0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count==128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file","scanline overrun"); + + if (!stbi__readval(s,packet->channel,value)) + return 0; + + for(i=0;i<count;++i, dest += 4) + stbi__copyval(packet->channel,dest,value); + } else { // Raw + ++count; + if (count>left) return stbi__errpuc("bad file","scanline overrun"); + + for(i=0;i<count;++i, dest+=4) + if (!stbi__readval(s,packet->channel,dest)) + return 0; + } + left-=count; + } + break; + } + } + } + } + + return result; +} + +static stbi_uc *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp) +{ + stbi_uc *result; + int i, x,y; + + for (i=0; i<92; ++i) + stbi__get8(s); + + x = stbi__get16be(s); + y = stbi__get16be(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); + if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to decode"); + + stbi__get32be(s); //skip `ratio' + stbi__get16be(s); //skip `fields' + stbi__get16be(s); //skip `pad' + + // intermediate buffer is RGBA + result = (stbi_uc *) stbi__malloc(x*y*4); + memset(result, 0xff, x*y*4); + + if (!stbi__pic_load_core(s,x,y,comp, result)) { + STBI_FREE(result); + result=0; + } + *px = x; + *py = y; + if (req_comp == 0) req_comp = *comp; + result=stbi__convert_format(result,4,req_comp,x,y); + + return result; +} + +static int stbi__pic_test(stbi__context *s) +{ + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; +} +#endif + +// ************************************************************************************************* +// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb + +#ifndef STBI_NO_GIF +typedef struct +{ + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; +} stbi__gif_lzw; + +typedef struct +{ + int w,h; + stbi_uc *out, *old_out; // output buffer (always 4 components) + int flags, bgindex, ratio, transparent, eflags, delay; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[4096]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; +} stbi__gif; + +static int stbi__gif_test_raw(stbi__context *s) +{ + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') return 0; + if (stbi__get8(s) != 'a') return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) +{ + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) +{ + int i; + for (i=0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) +{ + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + + if (is_info) return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__gif g; + if (!stbi__gif_header(s, &g, comp, 1)) { + stbi__rewind( s ); + return 0; + } + if (x) *x = g.w; + if (y) *y = g.h; + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) +{ + stbi_uc *p, *c; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) return; + + p = &g->out[g->cur_x + g->cur_y]; + c = &g->color_table[g->codes[code].suffix * 4]; + + if (c[3] >= 128) { + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) +{ + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc) init_code; + g->codes[init_code].suffix = (stbi_uc) init_code; + } + + // support no starting clear code + avail = clear+2; + oldcode = -1; + + len = 0; + for(;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32) stbi__get8(s) << valid_bits; + valid_bits += 8; + } else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s,len); + return g->out; + } else if (code <= avail) { + if (first) return stbi__errpuc("no clear code", "Corrupt GIF"); + + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 4096) return stbi__errpuc("too many codes", "Corrupt GIF"); + p->prefix = (stbi__int16) oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + + stbi__out_gif_code(g, (stbi__uint16) code); + + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } + + oldcode = code; + } else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +static void stbi__fill_gif_background(stbi__gif *g, int x0, int y0, int x1, int y1) +{ + int x, y; + stbi_uc *c = g->pal[g->bgindex]; + for (y = y0; y < y1; y += 4 * g->w) { + for (x = x0; x < x1; x += 4) { + stbi_uc *p = &g->out[y + x]; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = 0; + } + } +} + +// this function is designed to support animated gifs, although stb_image doesn't support it +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp) +{ + int i; + stbi_uc *prev_out = 0; + + if (g->out == 0 && !stbi__gif_header(s, g, comp,0)) + return 0; // stbi__g_failure_reason set by stbi__gif_header + + prev_out = g->out; + g->out = (stbi_uc *) stbi__malloc(4 * g->w * g->h); + if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); + + switch ((g->eflags & 0x1C) >> 2) { + case 0: // unspecified (also always used on 1st frame) + stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h); + break; + case 1: // do not dispose + if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); + g->old_out = prev_out; + break; + case 2: // dispose to background + if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); + stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y); + break; + case 3: // dispose to previous + if (g->old_out) { + for (i = g->start_y; i < g->max_y; i += 4 * g->w) + memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x); + } + break; + } + + for (;;) { + switch (stbi__get8(s)) { + case 0x2C: /* Image Descriptor */ + { + int prev_trans = -1; + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; + + g->lflags = stbi__get8(s); + + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } else { + g->step = g->line_size; + g->parse = 0; + } + + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *) g->lpal; + } else if (g->flags & 0x80) { + if (g->transparent >= 0 && (g->eflags & 0x01)) { + prev_trans = g->pal[g->transparent][3]; + g->pal[g->transparent][3] = 0; + } + g->color_table = (stbi_uc *) g->pal; + } else + return stbi__errpuc("missing color table", "Corrupt GIF"); + + o = stbi__process_gif_raster(s, g); + if (o == NULL) return NULL; + + if (prev_trans != -1) + g->pal[g->transparent][3] = (stbi_uc) prev_trans; + + return o; + } + + case 0x21: // Comment Extension. + { + int len; + if (stbi__get8(s) == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = stbi__get16le(s); + g->transparent = stbi__get8(s); + } else { + stbi__skip(s, len); + break; + } + } + while ((len = stbi__get8(s)) != 0) + stbi__skip(s, len); + break; + } + + case 0x3B: // gif stream termination code + return (stbi_uc *) s; // using '1' causes warning on some compilers + + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } + + STBI_NOTUSED(req_comp); +} + +static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + + u = stbi__gif_load_next(s, &g, comp, req_comp); + if (u == (stbi_uc *) s) u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } + else if (g.out) + STBI_FREE(g.out); + + return u; +} + +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) +{ + return stbi__gif_info_raw(s,x,y,comp); +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int stbi__hdr_test_core(stbi__context *s) +{ + const char *signature = "#?RADIANCE\n"; + int i; + for (i=0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + return 1; +} + +static int stbi__hdr_test(stbi__context* s) +{ + int r = stbi__hdr_test_core(s); + stbi__rewind(s); + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) +{ + int len=0; + char c = '\0'; + + c = (char) stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN-1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char) stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) +{ + if ( input[3] != 0 ) { + float f1; + // Exponent + f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) output[1] = 1; + if (req_comp == 4) output[3] = 1; + } else { + switch (req_comp) { + case 4: output[3] = 1; /* fallthrough */ + case 3: output[0] = output[1] = output[2] = 0; + break; + case 2: output[1] = 1; /* fallthrough */ + case 1: output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1,c2, z; + + + // Check identifier + if (strcmp(stbi__hdr_gettoken(s,buffer), "#?RADIANCE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int) strtol(token, NULL, 10); + + *x = width; + *y = height; + + if (comp) *comp = 3; + if (req_comp == 0) req_comp = 3; + + // Read data + hdr_data = (float *) stbi__malloc(height * width * req_comp * sizeof(float)); + + // Load image data + // image data is stored as some number of sca + if ( width < 8 || width >= 32768) { + // Read flat data + for (j=0; j < height; ++j) { + for (i=0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc) c1; + rgbe[1] = (stbi_uc) c2; + rgbe[2] = (stbi_uc) len; + rgbe[3] = (stbi_uc) stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense + } + len <<= 8; + len |= stbi__get8(s); + if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } + if (scanline == NULL) scanline = (stbi_uc *) stbi__malloc(width * 4); + + for (k = 0; k < 4; ++k) { + i = 0; + while (i < width) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } + } + for (i=0; i < width; ++i) + stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); + } + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + + if (strcmp(stbi__hdr_gettoken(s,buffer), "#?RADIANCE") != 0) { + stbi__rewind( s ); + return 0; + } + + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) { + stbi__rewind( s ); + return 0; + } + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *y = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *x = (int) strtol(token, NULL, 10); + *comp = 3; + return 1; +} +#endif // STBI_NO_HDR + +#ifndef STBI_NO_BMP +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) +{ + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') { + stbi__rewind( s ); + return 0; + } + stbi__skip(s,12); + hsz = stbi__get32le(s); + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) { + stbi__rewind( s ); + return 0; + } + if (hsz == 12) { + *x = stbi__get16le(s); + *y = stbi__get16le(s); + } else { + *x = stbi__get32le(s); + *y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) { + stbi__rewind( s ); + return 0; + } + *comp = stbi__get16le(s) / 8; + return 1; +} +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) +{ + int channelCount; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind( s ); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind( s ); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + if (stbi__get16be(s) != 8) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind( s ); + return 0; + } + *comp = 4; + return 1; +} +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) +{ + int act_comp=0,num_packets=0,chained; + stbi__pic_packet packets[10]; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind( s); + return 0; + } + if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind( s ); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return 0; + + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; + + if (stbi__at_eof(s)) { + stbi__rewind( s ); + return 0; + } + if (packet->size != 8) { + stbi__rewind( s ); + return 0; + } + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); + + return 1; +} +#endif + +// ************************************************************************************************* +// Portable Gray Map and Portable Pixel Map loader +// by Ken Miller +// +// PGM: http://netpbm.sourceforge.net/doc/pgm.html +// PPM: http://netpbm.sourceforge.net/doc/ppm.html +// +// Known limitations: +// Does not support comments in the header section +// Does not support ASCII image data (formats P2 and P3) +// Does not support 16-bit-per-channel + +#ifndef STBI_NO_PNM + +static int stbi__pnm_test(stbi__context *s) +{ + char p, t; + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind( s ); + return 0; + } + return 1; +} + +static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *out; + if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) + return 0; + *x = s->img_x; + *y = s->img_y; + *comp = s->img_n; + + out = (stbi_uc *) stbi__malloc(s->img_n * s->img_x * s->img_y); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + stbi__getn(s, out, s->img_n * s->img_x * s->img_y); + + if (req_comp && req_comp != s->img_n) { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + return out; +} + +static int stbi__pnm_isspace(char c) +{ + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +} + +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) +{ + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char) stbi__get8(s); +} + +static int stbi__pnm_isdigit(char c) +{ + return c >= '0' && c <= '9'; +} + +static int stbi__pnm_getinteger(stbi__context *s, char *c) +{ + int value = 0; + + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value*10 + (*c - '0'); + *c = (char) stbi__get8(s); + } + + return value; +} + +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) +{ + int maxv; + char c, p, t; + + stbi__rewind( s ); + + // Get identifier + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind( s ); + return 0; + } + + *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + + c = (char) stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); + + *x = stbi__pnm_getinteger(s, &c); // read width + stbi__pnm_skip_whitespace(s, &c); + + *y = stbi__pnm_getinteger(s, &c); // read height + stbi__pnm_skip_whitespace(s, &c); + + maxv = stbi__pnm_getinteger(s, &c); // read max value + + if (maxv > 255) + return stbi__err("max value > 255", "PPM image not 8-bit"); + else + return 1; +} +#endif + +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) +{ + #ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) return 1; + #endif + + // test tga last because it's a crappy test! + #ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; + #endif + return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s,x,y,comp); + fseek(f,pos,SEEK_SET); + return r; +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__info_main(&s,x,y,comp); +} + +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); + return stbi__info_main(&s,x,y,comp); +} + +#endif // STB_IMAGE_IMPLEMENTATION + +/* + revision history: + 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA + 2.07 (2015-09-13) fix compiler warnings + partial animated GIF support + limited 16-bit PSD support + #ifdef unused functions + bug with < 92 byte PIC,PNM,HDR,TGA + 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value + 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning + 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit + 2.03 (2015-04-12) extra corruption checking (mmozeiko) + stbi_set_flip_vertically_on_load (nguillemot) + fix NEON support; fix mingw support + 2.02 (2015-01-19) fix incorrect assert, fix warning + 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 + 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG + 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) + progressive JPEG (stb) + PGM/PPM support (Ken Miller) + STBI_MALLOC,STBI_REALLOC,STBI_FREE + GIF bugfix -- seemingly never worked + STBI_NO_*, STBI_ONLY_* + 1.48 (2014-12-14) fix incorrectly-named assert() + 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) + optimize PNG (ryg) + fix bug in interlaced PNG with user-specified channel count (stb) + 1.46 (2014-08-26) + fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG + 1.45 (2014-08-16) + fix MSVC-ARM internal compiler error by wrapping malloc + 1.44 (2014-08-07) + various warning fixes from Ronny Chevalier + 1.43 (2014-07-15) + fix MSVC-only compiler problem in code changed in 1.42 + 1.42 (2014-07-09) + don't define _CRT_SECURE_NO_WARNINGS (affects user code) + fixes to stbi__cleanup_jpeg path + added STBI_ASSERT to avoid requiring assert.h + 1.41 (2014-06-25) + fix search&replace from 1.36 that messed up comments/error messages + 1.40 (2014-06-22) + fix gcc struct-initialization warning + 1.39 (2014-06-15) + fix to TGA optimization when req_comp != number of components in TGA; + fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) + add support for BMP version 5 (more ignored fields) + 1.38 (2014-06-06) + suppress MSVC warnings on integer casts truncating values + fix accidental rename of 'skip' field of I/O + 1.37 (2014-06-04) + remove duplicate typedef + 1.36 (2014-06-03) + convert to header file single-file library + if de-iphone isn't set, load iphone images color-swapped instead of returning NULL + 1.35 (2014-05-27) + various warnings + fix broken STBI_SIMD path + fix bug where stbi_load_from_file no longer left file pointer in correct place + fix broken non-easy path for 32-bit BMP (possibly never used) + TGA optimization by Arseny Kapoulkine + 1.34 (unknown) + use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case + 1.33 (2011-07-14) + make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements + 1.32 (2011-07-13) + support for "info" function for all supported filetypes (SpartanJ) + 1.31 (2011-06-20) + a few more leak fixes, bug in PNG handling (SpartanJ) + 1.30 (2011-06-11) + added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) + removed deprecated format-specific test/load functions + removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway + error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) + fix inefficiency in decoding 32-bit BMP (David Woo) + 1.29 (2010-08-16) + various warning fixes from Aurelien Pocheville + 1.28 (2010-08-01) + fix bug in GIF palette transparency (SpartanJ) + 1.27 (2010-08-01) + cast-to-stbi_uc to fix warnings + 1.26 (2010-07-24) + fix bug in file buffering for PNG reported by SpartanJ + 1.25 (2010-07-17) + refix trans_data warning (Won Chun) + 1.24 (2010-07-12) + perf improvements reading from files on platforms with lock-heavy fgetc() + minor perf improvements for jpeg + deprecated type-specific functions so we'll get feedback if they're needed + attempt to fix trans_data warning (Won Chun) + 1.23 fixed bug in iPhone support + 1.22 (2010-07-10) + removed image *writing* support + stbi_info support from Jetro Lauha + GIF support from Jean-Marc Lienher + iPhone PNG-extensions from James Brown + warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) + 1.21 fix use of 'stbi_uc' in header (reported by jon blow) + 1.20 added support for Softimage PIC, by Tom Seddon + 1.19 bug in interlaced PNG corruption check (found by ryg) + 1.18 (2008-08-02) + fix a threading bug (local mutable static) + 1.17 support interlaced PNG + 1.16 major bugfix - stbi__convert_format converted one too many pixels + 1.15 initialize some fields for thread safety + 1.14 fix threadsafe conversion bug + header-file-only version (#define STBI_HEADER_FILE_ONLY before including) + 1.13 threadsafe + 1.12 const qualifiers in the API + 1.11 Support installable IDCT, colorspace conversion routines + 1.10 Fixes for 64-bit (don't use "unsigned long") + optimized upsampling by Fabian "ryg" Giesen + 1.09 Fix format-conversion for PSD code (bad global variables!) + 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz + 1.07 attempt to fix C++ warning/errors again + 1.06 attempt to fix C++ warning/errors again + 1.05 fix TGA loading to return correct *comp and use good luminance calc + 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free + 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR + 1.02 support for (subset of) HDR files, float interface for preferred access to them + 1.01 fix bug: possible bug in handling right-side up bmps... not sure + fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all + 1.00 interface to zlib that skips zlib header + 0.99 correct handling of alpha in palette + 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 0.97 jpeg errors on too large a file; also catch another malloc failure + 0.96 fix detection of invalid v value - particleman@mollyrocket forum + 0.95 during header scan, seek to markers in case of padding + 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same + 0.93 handle jpegtran output; verbose errors + 0.92 read 4,8,16,24,32-bit BMP files of several formats + 0.91 output 24-bit Windows 3.0 BMP files + 0.90 fix a few more warnings; bump version number to approach 1.0 + 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd + 0.60 fix compiling as c++ + 0.59 fix warnings: merge Dave Moore's -Wall fixes + 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available + 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.55 fix bug: restart_interval not initialized to 0 + 0.54 allow NULL for 'int *comp' + 0.53 fix bug in png 3->4; speedup png decoding + 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments + 0.51 obey req_comp requests, 1-component jpegs return as 1-component, + on 'test' only check type, not whether we support this variant + 0.50 (2006-11-19) + first released version +*/ diff --git a/foreign/stb_image_resize.h b/foreign/stb_image_resize.h new file mode 100644 index 0000000..088c88a --- /dev/null +++ b/foreign/stb_image_resize.h @@ -0,0 +1,2586 @@ +/* stb_image_resize - v0.90 - public domain image resizing + by Jorge L Rodriguez (@VinoBS) - 2014 + http://github.com/nothings/stb + + Written with emphasis on usability, portability, and efficiency. (No + SIMD or threads, so it be easily outperformed by libs that use those.) + Only scaling and translation is supported, no rotations or shears. + Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation. + + COMPILING & LINKING + In one C/C++ file that #includes this file, do this: + #define STB_IMAGE_RESIZE_IMPLEMENTATION + before the #include. That will create the implementation in that file. + + QUICKSTART + stbir_resize_uint8( input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, num_channels) + stbir_resize_float(...) + stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, + num_channels , alpha_chan , 0) + stbir_resize_uint8_srgb_edgemode( + input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, + num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP) + // WRAP/REFLECT/ZERO + + FULL API + See the "header file" section of the source for API documentation. + + ADDITIONAL DOCUMENTATION + + SRGB & FLOATING POINT REPRESENTATION + The sRGB functions presume IEEE floating point. If you do not have + IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use + a slower implementation. + + MEMORY ALLOCATION + The resize functions here perform a single memory allocation using + malloc. To control the memory allocation, before the #include that + triggers the implementation, do: + + #define STBIR_MALLOC(size,context) ... + #define STBIR_FREE(ptr,context) ... + + Each resize function makes exactly one call to malloc/free, so to use + temp memory, store the temp memory in the context and return that. + + ASSERT + Define STBIR_ASSERT(boolval) to override assert() and not use assert.h + + OPTIMIZATION + Define STBIR_SATURATE_INT to compute clamp values in-range using + integer operations instead of float operations. This may be faster + on some platforms. + + DEFAULT FILTERS + For functions which don't provide explicit control over what filters + to use, you can change the compile-time defaults with + + #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something + #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something + + See stbir_filter in the header-file section for the list of filters. + + NEW FILTERS + A number of 1D filter kernels are used. For a list of + supported filters see the stbir_filter enum. To add a new filter, + write a filter function and add it to stbir__filter_info_table. + + PROGRESS + For interactive use with slow resize operations, you can install + a progress-report callback: + + #define STBIR_PROGRESS_REPORT(val) some_func(val) + + The parameter val is a float which goes from 0 to 1 as progress is made. + + For example: + + static void my_progress_report(float progress); + #define STBIR_PROGRESS_REPORT(val) my_progress_report(val) + + #define STB_IMAGE_RESIZE_IMPLEMENTATION + #include "stb_image_resize.h" + + static void my_progress_report(float progress) + { + printf("Progress: %f%%\n", progress*100); + } + + MAX CHANNELS + If your image has more than 64 channels, define STBIR_MAX_CHANNELS + to the max you'll have. + + ALPHA CHANNEL + Most of the resizing functions provide the ability to control how + the alpha channel of an image is processed. The important things + to know about this: + + 1. The best mathematically-behaved version of alpha to use is + called "premultiplied alpha", in which the other color channels + have had the alpha value multiplied in. If you use premultiplied + alpha, linear filtering (such as image resampling done by this + library, or performed in texture units on GPUs) does the "right + thing". While premultiplied alpha is standard in the movie CGI + industry, it is still uncommon in the videogame/real-time world. + + If you linearly filter non-premultiplied alpha, strange effects + occur. (For example, the average of 1% opaque bright green + and 99% opaque black produces 50% transparent dark green when + non-premultiplied, whereas premultiplied it produces 50% + transparent near-black. The former introduces green energy + that doesn't exist in the source image.) + + 2. Artists should not edit premultiplied-alpha images; artists + want non-premultiplied alpha images. Thus, art tools generally output + non-premultiplied alpha images. + + 3. You will get best results in most cases by converting images + to premultiplied alpha before processing them mathematically. + + 4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the + resizer does not do anything special for the alpha channel; + it is resampled identically to other channels. This produces + the correct results for premultiplied-alpha images, but produces + less-than-ideal results for non-premultiplied-alpha images. + + 5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, + then the resizer weights the contribution of input pixels + based on their alpha values, or, equivalently, it multiplies + the alpha value into the color channels, resamples, then divides + by the resultant alpha value. Input pixels which have alpha=0 do + not contribute at all to output pixels unless _all_ of the input + pixels affecting that output pixel have alpha=0, in which case + the result for that pixel is the same as it would be without + STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for + input images in integer formats. For input images in float format, + input pixels with alpha=0 have no effect, and output pixels + which have alpha=0 will be 0 in all channels. (For float images, + you can manually achieve the same result by adding a tiny epsilon + value to the alpha channel of every image, and then subtracting + or clamping it at the end.) + + 6. You can suppress the behavior described in #5 and make + all-0-alpha pixels have 0 in all channels by #defining + STBIR_NO_ALPHA_EPSILON. + + 7. You can separately control whether the alpha channel is + interpreted as linear or affected by the colorspace. By default + it is linear; you almost never want to apply the colorspace. + (For example, graphics hardware does not apply sRGB conversion + to the alpha channel.) + + ADDITIONAL CONTRIBUTORS + Sean Barrett: API design, optimizations + + REVISIONS + 0.90 (2014-09-17) first released version + + LICENSE + + This software is in the public domain. Where that dedication is not + recognized, you are granted a perpetual, irrevocable license to copy, + distribute, and modify this file as you see fit. + + TODO + Don't decode all of the image data when only processing a partial tile + Don't use full-width decode buffers when only processing a partial tile + When processing wide images, break processing into tiles so data fits in L1 cache + Installable filters? + Resize that respects alpha test coverage + (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage: + https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp ) +*/ + +#ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H +#define STBIR_INCLUDE_STB_IMAGE_RESIZE_H + +#ifdef _MSC_VER +typedef unsigned char stbir_uint8; +typedef unsigned short stbir_uint16; +typedef unsigned int stbir_uint32; +#else +#include <stdint.h> +typedef uint8_t stbir_uint8; +typedef uint16_t stbir_uint16; +typedef uint32_t stbir_uint32; +#endif + +#ifdef STB_IMAGE_RESIZE_STATIC +#define STBIRDEF static +#else +#ifdef __cplusplus +#define STBIRDEF extern "C" +#else +#define STBIRDEF extern +#endif +#endif + + +////////////////////////////////////////////////////////////////////////////// +// +// Easy-to-use API: +// +// * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4) +// * input_w is input image width (x-axis), input_h is input image height (y-axis) +// * stride is the offset between successive rows of image data in memory, in bytes. you can +// specify 0 to mean packed continuously in memory +// * alpha channel is treated identically to other channels. +// * colorspace is linear or sRGB as specified by function name +// * returned result is 1 for success or 0 in case of an error. +// #define STBIR_ASSERT() to trigger an assert on parameter validation errors. +// * Memory required grows approximately linearly with input and output size, but with +// discontinuities at input_w == output_w and input_h == output_h. +// * These functions use a "default" resampling filter defined at compile time. To change the filter, +// you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE +// and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API. + +STBIRDEF int stbir_resize_uint8(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels); + +STBIRDEF int stbir_resize_float(const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels); + + +// The following functions interpret image data as gamma-corrected sRGB. +// Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel, +// or otherwise provide the index of the alpha channel. Flags value +// of 0 will probably do the right thing if you're not sure what +// the flags mean. + +#define STBIR_ALPHA_CHANNEL_NONE -1 + +// Set this flag if your texture has premultiplied alpha. Otherwise, stbir will +// use alpha-weighted resampling (effectively premultiplying, resampling, +// then unpremultiplying). +#define STBIR_FLAG_ALPHA_PREMULTIPLIED (1 << 0) +// The specified alpha channel should be handled as gamma-corrected value even +// when doing sRGB operations. +#define STBIR_FLAG_ALPHA_USES_COLORSPACE (1 << 1) + +STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags); + + +typedef enum +{ + STBIR_EDGE_CLAMP = 1, + STBIR_EDGE_REFLECT = 2, + STBIR_EDGE_WRAP = 3, + STBIR_EDGE_ZERO = 4, +} stbir_edge; + +// This function adds the ability to specify how requests to sample off the edge of the image are handled. +STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode); + +////////////////////////////////////////////////////////////////////////////// +// +// Medium-complexity API +// +// This extends the easy-to-use API as follows: +// +// * Alpha-channel can be processed separately +// * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE +// * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT) +// * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED) +// * Filter can be selected explicitly +// * uint16 image type +// * sRGB colorspace available for all types +// * context parameter for passing to STBIR_MALLOC + +typedef enum +{ + STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses + STBIR_FILTER_BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios + STBIR_FILTER_TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering + STBIR_FILTER_CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque + STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline + STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 +} stbir_filter; + +typedef enum +{ + STBIR_COLORSPACE_LINEAR, + STBIR_COLORSPACE_SRGB, + + STBIR_MAX_COLORSPACES, +} stbir_colorspace; + +// The following functions are all identical except for the type of the image data + +STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + +STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + +STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + + + +////////////////////////////////////////////////////////////////////////////// +// +// Full-complexity API +// +// This extends the medium API as follows: +// +// * uint32 image type +// * not typesafe +// * separate filter types for each axis +// * separate edge modes for each axis +// * can specify scale explicitly for subpixel correctness +// * can specify image source tile using texture coordinates + +typedef enum +{ + STBIR_TYPE_UINT8 , + STBIR_TYPE_UINT16, + STBIR_TYPE_UINT32, + STBIR_TYPE_FLOAT , + + STBIR_MAX_TYPES +} stbir_datatype; + +STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context); + +STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float x_scale, float y_scale, + float x_offset, float y_offset); + +STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float s0, float t0, float s1, float t1); +// (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use. + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H + + + + + +#ifdef STB_IMAGE_RESIZE_IMPLEMENTATION + +#ifndef STBIR_ASSERT +#include <assert.h> +#define STBIR_ASSERT(x) assert(x) +#endif + +#ifdef STBIR_DEBUG +#define STBIR__DEBUG_ASSERT STBIR_ASSERT +#else +#define STBIR__DEBUG_ASSERT +#endif + +// If you hit this it means I haven't done it yet. +#define STBIR__UNIMPLEMENTED(x) STBIR_ASSERT(!(x)) + +// For memset +#include <string.h> + +#include <math.h> + +#ifndef STBIR_MALLOC +#include <stdlib.h> +#define STBIR_MALLOC(size,c) malloc(size) +#define STBIR_FREE(ptr,c) free(ptr) +#endif + +#ifndef _MSC_VER +#ifdef __cplusplus +#define stbir__inline inline +#else +#define stbir__inline +#endif +#else +#define stbir__inline __forceinline +#endif + + +// should produce compiler error if size is wrong +typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBIR__NOTUSED(v) (void)(v) +#else +#define STBIR__NOTUSED(v) (void)sizeof(v) +#endif + +#define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0])) + +#ifndef STBIR_DEFAULT_FILTER_UPSAMPLE +#define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM +#endif + +#ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE +#define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL +#endif + +#ifndef STBIR_PROGRESS_REPORT +#define STBIR_PROGRESS_REPORT(float_0_to_1) +#endif + +#ifndef STBIR_MAX_CHANNELS +#define STBIR_MAX_CHANNELS 64 +#endif + +#if STBIR_MAX_CHANNELS > 65536 +#error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536." +// because we store the indices in 16-bit variables +#endif + +// This value is added to alpha just before premultiplication to avoid +// zeroing out color values. It is equivalent to 2^-80. If you don't want +// that behavior (it may interfere if you have floating point images with +// very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to +// disable it. +#ifndef STBIR_ALPHA_EPSILON +#define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) +#endif + + + +#ifdef _MSC_VER +#define STBIR__UNUSED_PARAM(v) (void)(v) +#else +#define STBIR__UNUSED_PARAM(v) (void)sizeof(v) +#endif + +// must match stbir_datatype +static unsigned char stbir__type_size[] = { + 1, // STBIR_TYPE_UINT8 + 2, // STBIR_TYPE_UINT16 + 4, // STBIR_TYPE_UINT32 + 4, // STBIR_TYPE_FLOAT +}; + +// Kernel function centered at 0 +typedef float (stbir__kernel_fn)(float x, float scale); +typedef float (stbir__support_fn)(float scale); + +typedef struct +{ + stbir__kernel_fn* kernel; + stbir__support_fn* support; +} stbir__filter_info; + +// When upsampling, the contributors are which source pixels contribute. +// When downsampling, the contributors are which destination pixels are contributed to. +typedef struct +{ + int n0; // First contributing pixel + int n1; // Last contributing pixel +} stbir__contributors; + +typedef struct +{ + const void* input_data; + int input_w; + int input_h; + int input_stride_bytes; + + void* output_data; + int output_w; + int output_h; + int output_stride_bytes; + + float s0, t0, s1, t1; + + float horizontal_shift; // Units: output pixels + float vertical_shift; // Units: output pixels + float horizontal_scale; + float vertical_scale; + + int channels; + int alpha_channel; + stbir_uint32 flags; + stbir_datatype type; + stbir_filter horizontal_filter; + stbir_filter vertical_filter; + stbir_edge edge_horizontal; + stbir_edge edge_vertical; + stbir_colorspace colorspace; + + stbir__contributors* horizontal_contributors; + float* horizontal_coefficients; + + stbir__contributors* vertical_contributors; + float* vertical_coefficients; + + int decode_buffer_pixels; + float* decode_buffer; + + float* horizontal_buffer; + + // cache these because ceil/floor are inexplicably showing up in profile + int horizontal_coefficient_width; + int vertical_coefficient_width; + int horizontal_filter_pixel_width; + int vertical_filter_pixel_width; + int horizontal_filter_pixel_margin; + int vertical_filter_pixel_margin; + int horizontal_num_contributors; + int vertical_num_contributors; + + int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter) + int ring_buffer_first_scanline; + int ring_buffer_last_scanline; + int ring_buffer_begin_index; + float* ring_buffer; + + float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds. + + int horizontal_contributors_size; + int horizontal_coefficients_size; + int vertical_contributors_size; + int vertical_coefficients_size; + int decode_buffer_size; + int horizontal_buffer_size; + int ring_buffer_size; + int encode_buffer_size; +} stbir__info; + +static stbir__inline int stbir__min(int a, int b) +{ + return a < b ? a : b; +} + +static stbir__inline int stbir__max(int a, int b) +{ + return a > b ? a : b; +} + +static stbir__inline float stbir__saturate(float x) +{ + if (x < 0) + return 0; + + if (x > 1) + return 1; + + return x; +} + +#ifdef STBIR_SATURATE_INT +static stbir__inline stbir_uint8 stbir__saturate8(int x) +{ + if ((unsigned int) x <= 255) + return x; + + if (x < 0) + return 0; + + return 255; +} + +static stbir__inline stbir_uint16 stbir__saturate16(int x) +{ + if ((unsigned int) x <= 65535) + return x; + + if (x < 0) + return 0; + + return 65535; +} +#endif + +static float stbir__srgb_uchar_to_linear_float[256] = { + 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, + 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, + 0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f, + 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f, + 0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, + 0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f, + 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, + 0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, + 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f, + 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, + 0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f, + 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f, + 0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, + 0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f, + 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, + 0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, + 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f, + 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, + 0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f, + 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f, + 0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, + 0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f, + 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, + 0.982251f, 0.991102f, 1.0f +}; + +static float stbir__srgb_to_linear(float f) +{ + if (f <= 0.04045f) + return f / 12.92f; + else + return (float)pow((f + 0.055f) / 1.055f, 2.4f); +} + +static float stbir__linear_to_srgb(float f) +{ + if (f <= 0.0031308f) + return f * 12.92f; + else + return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f; +} + +#ifndef STBIR_NON_IEEE_FLOAT +// From https://gist.github.com/rygorous/2203834 + +typedef union +{ + stbir_uint32 u; + float f; +} stbir__FP32; + +static const stbir_uint32 fp32_to_srgb8_tab4[104] = { + 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, + 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, + 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, + 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, + 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, + 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, + 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, + 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, + 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, + 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, + 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, + 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, + 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, +}; + +static stbir_uint8 stbir__linear_to_srgb_uchar(float in) +{ + static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps + static const stbir__FP32 minval = { (127-13) << 23 }; + stbir_uint32 tab,bias,scale,t; + stbir__FP32 f; + + // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. + // The tests are carefully written so that NaNs map to 0, same as in the reference + // implementation. + if (!(in > minval.f)) // written this way to catch NaNs + in = minval.f; + if (in > almostone.f) + in = almostone.f; + + // Do the table lookup and unpack bias, scale + f.f = in; + tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; + bias = (tab >> 16) << 9; + scale = tab & 0xffff; + + // Grab next-highest mantissa bits and perform linear interpolation + t = (f.u >> 12) & 0xff; + return (unsigned char) ((bias + scale*t) >> 16); +} + +#else +// sRGB transition values, scaled by 1<<28 +static int stbir__srgb_offset_to_linear_scaled[256] = +{ + 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603, + 611080, 692557, 774035, 855852, 942009, 1033024, 1128971, 1229926, + 1335959, 1447142, 1563542, 1685229, 1812268, 1944725, 2082664, 2226148, + 2375238, 2529996, 2690481, 2856753, 3028870, 3206888, 3390865, 3580856, + 3776916, 3979100, 4187460, 4402049, 4622919, 4850123, 5083710, 5323731, + 5570236, 5823273, 6082892, 6349140, 6622065, 6901714, 7188133, 7481369, + 7781466, 8088471, 8402427, 8723380, 9051372, 9386448, 9728650, 10078021, + 10434603, 10798439, 11169569, 11548036, 11933879, 12327139, 12727857, 13136073, + 13551826, 13975156, 14406100, 14844697, 15290987, 15745007, 16206795, 16676389, + 17153826, 17639142, 18132374, 18633560, 19142734, 19659934, 20185196, 20718552, + 21260042, 21809696, 22367554, 22933648, 23508010, 24090680, 24681686, 25281066, + 25888850, 26505076, 27129772, 27762974, 28404716, 29055026, 29713942, 30381490, + 31057708, 31742624, 32436272, 33138682, 33849884, 34569912, 35298800, 36036568, + 36783260, 37538896, 38303512, 39077136, 39859796, 40651528, 41452360, 42262316, + 43081432, 43909732, 44747252, 45594016, 46450052, 47315392, 48190064, 49074096, + 49967516, 50870356, 51782636, 52704392, 53635648, 54576432, 55526772, 56486700, + 57456236, 58435408, 59424248, 60422780, 61431036, 62449032, 63476804, 64514376, + 65561776, 66619028, 67686160, 68763192, 69850160, 70947088, 72053992, 73170912, + 74297864, 75434880, 76581976, 77739184, 78906536, 80084040, 81271736, 82469648, + 83677792, 84896192, 86124888, 87363888, 88613232, 89872928, 91143016, 92423512, + 93714432, 95015816, 96327688, 97650056, 98982952, 100326408, 101680440, 103045072, + 104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544, + 115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832, + 127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528, + 140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968, + 154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184, + 168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992, + 183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968, + 199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480, + 215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656, + 232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464, + 250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664, +}; + +static stbir_uint8 stbir__linear_to_srgb_uchar(float f) +{ + int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp + int v = 0; + int i; + + // Refine the guess with a short binary search. + i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + + return (stbir_uint8) v; +} +#endif + +static float stbir__filter_trapezoid(float x, float scale) +{ + float halfscale = scale / 2; + float t = 0.5f + halfscale; + STBIR__DEBUG_ASSERT(scale <= 1); + + x = (float)fabs(x); + + if (x >= t) + return 0; + else + { + float r = 0.5f - halfscale; + if (x <= r) + return 1; + else + return (t - x) / scale; + } +} + +static float stbir__support_trapezoid(float scale) +{ + STBIR__DEBUG_ASSERT(scale <= 1); + return 0.5f + scale / 2; +} + +static float stbir__filter_triangle(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x <= 1.0f) + return 1 - x; + else + return 0; +} + +static float stbir__filter_cubic(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return (4 + x*x*(3*x - 6))/6; + else if (x < 2.0f) + return (8 + x*(-12 + x*(6 - x)))/6; + + return (0.0f); +} + +static float stbir__filter_catmullrom(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return 1 - x*x*(2.5f - 1.5f*x); + else if (x < 2.0f) + return 2 - x*(4 + x*(0.5f*x - 2.5f)); + + return (0.0f); +} + +static float stbir__filter_mitchell(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return (16 + x*x*(21 * x - 36))/18; + else if (x < 2.0f) + return (32 + x*(-60 + x*(36 - 7*x)))/18; + + return (0.0f); +} + +static float stbir__support_zero(float s) +{ + STBIR__UNUSED_PARAM(s); + return 0; +} + +static float stbir__support_one(float s) +{ + STBIR__UNUSED_PARAM(s); + return 1; +} + +static float stbir__support_two(float s) +{ + STBIR__UNUSED_PARAM(s); + return 2; +} + +static stbir__filter_info stbir__filter_info_table[] = { + { NULL, stbir__support_zero }, + { stbir__filter_trapezoid, stbir__support_trapezoid }, + { stbir__filter_triangle, stbir__support_one }, + { stbir__filter_cubic, stbir__support_two }, + { stbir__filter_catmullrom, stbir__support_two }, + { stbir__filter_mitchell, stbir__support_two }, +}; + +stbir__inline static int stbir__use_upsampling(float ratio) +{ + return ratio > 1; +} + +stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info) +{ + return stbir__use_upsampling(stbir_info->horizontal_scale); +} + +stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info) +{ + return stbir__use_upsampling(stbir_info->vertical_scale); +} + +// This is the maximum number of input samples that can affect an output sample +// with the given filter +static int stbir__get_filter_pixel_width(stbir_filter filter, float scale) +{ + STBIR_ASSERT(filter != 0); + STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + + if (stbir__use_upsampling(scale)) + return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2); + else + return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale); +} + +// This is how much to expand buffers to account for filters seeking outside +// the image boundaries. +static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale) +{ + return stbir__get_filter_pixel_width(filter, scale) / 2; +} + +static int stbir__get_coefficient_width(stbir_filter filter, float scale) +{ + if (stbir__use_upsampling(scale)) + return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2); + else + return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2); +} + +static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size) +{ + if (stbir__use_upsampling(scale)) + return output_size; + else + return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2); +} + +static int stbir__get_total_horizontal_coefficients(stbir__info* info) +{ + return info->horizontal_num_contributors + * stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); +} + +static int stbir__get_total_vertical_coefficients(stbir__info* info) +{ + return info->vertical_num_contributors + * stbir__get_coefficient_width (info->vertical_filter, info->vertical_scale); +} + +static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n) +{ + return &contributors[n]; +} + +// For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample, +// if you change it here change it there too. +static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c) +{ + int width = stbir__get_coefficient_width(filter, scale); + return &coefficients[width*n + c]; +} + +static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) +{ + switch (edge) + { + case STBIR_EDGE_ZERO: + return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later + + case STBIR_EDGE_CLAMP: + if (n < 0) + return 0; + + if (n >= max) + return max - 1; + + return n; // NOTREACHED + + case STBIR_EDGE_REFLECT: + { + if (n < 0) + { + if (n < max) + return -n; + else + return max - 1; + } + + if (n >= max) + { + int max2 = max * 2; + if (n >= max2) + return 0; + else + return max2 - n - 1; + } + + return n; // NOTREACHED + } + + case STBIR_EDGE_WRAP: + if (n >= 0) + return (n % max); + else + { + int m = (-n) % max; + + if (m != 0) + m = max - m; + + return (m); + } + //return n; // NOTREACHED + + default: + STBIR__UNIMPLEMENTED("Unimplemented edge type"); + return 0; + } +} + +stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) +{ + // avoid per-pixel switch + if (n >= 0 && n < max) + return n; + return stbir__edge_wrap_slow(edge, n, max); +} + +// What input pixels contribute to this output pixel? +static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out) +{ + float out_pixel_center = (float)n + 0.5f; + float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; + float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; + + float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio; + float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio; + + *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio; + *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5)); + *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5)); +} + +// What output pixels does this input pixel contribute to? +static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in) +{ + float in_pixel_center = (float)n + 0.5f; + float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; + float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; + + float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift; + float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift; + + *out_center_of_in = in_pixel_center * scale_ratio - out_shift; + *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5)); + *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5)); +} + +static void stbir__calculate_coefficients_upsample(stbir__info* stbir_info, stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group) +{ + int i; + float total_filter = 0; + float filter_scale; + + STBIR__DEBUG_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. + + contributor->n0 = in_first_pixel; + contributor->n1 = in_last_pixel; + + STBIR__DEBUG_ASSERT(contributor->n1 >= contributor->n0); + + for (i = 0; i <= in_last_pixel - in_first_pixel; i++) + { + float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; + coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale); + + // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.) + if (i == 0 && !coefficient_group[i]) + { + contributor->n0 = ++in_first_pixel; + i--; + continue; + } + + total_filter += coefficient_group[i]; + } + + STBIR__DEBUG_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0); + + STBIR__DEBUG_ASSERT(total_filter > 0.9); + STBIR__DEBUG_ASSERT(total_filter < 1.1f); // Make sure it's not way off. + + // Make sure the sum of all coefficients is 1. + filter_scale = 1 / total_filter; + + for (i = 0; i <= in_last_pixel - in_first_pixel; i++) + coefficient_group[i] *= filter_scale; + + for (i = in_last_pixel - in_first_pixel; i >= 0; i--) + { + if (coefficient_group[i]) + break; + + // This line has no weight. We can skip it. + contributor->n1 = contributor->n0 + i - 1; + } +} + +static void stbir__calculate_coefficients_downsample(stbir__info* stbir_info, stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group) +{ + int i; + + STBIR__DEBUG_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. + + contributor->n0 = out_first_pixel; + contributor->n1 = out_last_pixel; + + STBIR__DEBUG_ASSERT(contributor->n1 >= contributor->n0); + + for (i = 0; i <= out_last_pixel - out_first_pixel; i++) + { + float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; + float x = out_pixel_center - out_center_of_in; + coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio; + } + + STBIR__DEBUG_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0); + + for (i = out_last_pixel - out_first_pixel; i >= 0; i--) + { + if (coefficient_group[i]) + break; + + // This line has no weight. We can skip it. + contributor->n1 = contributor->n0 + i - 1; + } +} + +static void stbir__normalize_downsample_coefficients(stbir__info* stbir_info, stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) +{ + int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); + int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio); + int i, j; + int skip; + + for (i = 0; i < output_size; i++) + { + float scale; + float total = 0; + + for (j = 0; j < num_contributors; j++) + { + if (i >= contributors[j].n0 && i <= contributors[j].n1) + { + float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0); + total += coefficient; + } + else if (i < contributors[j].n0) + break; + } + + STBIR__DEBUG_ASSERT(total > 0.9f); + STBIR__DEBUG_ASSERT(total < 1.1f); + + scale = 1 / total; + + for (j = 0; j < num_contributors; j++) + { + if (i >= contributors[j].n0 && i <= contributors[j].n1) + *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale; + else if (i < contributors[j].n0) + break; + } + } + + // Optimize: Skip zero coefficients and contributions outside of image bounds. + // Do this after normalizing because normalization depends on the n0/n1 values. + for (j = 0; j < num_contributors; j++) + { + int range, max, width; + + skip = 0; + while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0) + skip++; + + contributors[j].n0 += skip; + + while (contributors[j].n0 < 0) + { + contributors[j].n0++; + skip++; + } + + range = contributors[j].n1 - contributors[j].n0 + 1; + max = stbir__min(num_coefficients, range); + + width = stbir__get_coefficient_width(filter, scale_ratio); + for (i = 0; i < max; i++) + { + if (i + skip >= width) + break; + + *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip); + } + + continue; + } + + // Using min to avoid writing into invalid pixels. + for (i = 0; i < num_contributors; i++) + contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1); +} + +// Each scan line uses the same kernel values so we should calculate the kernel +// values once and then we can use them for every scan line. +static void stbir__calculate_filters(stbir__info* stbir_info, stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) +{ + int n; + int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); + + if (stbir__use_upsampling(scale_ratio)) + { + float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio; + + // Looping through out pixels + for (n = 0; n < total_contributors; n++) + { + float in_center_of_out; // Center of the current out pixel in the in pixel space + int in_first_pixel, in_last_pixel; + + stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out); + + stbir__calculate_coefficients_upsample(stbir_info, filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); + } + } + else + { + float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio; + + // Looping through in pixels + for (n = 0; n < total_contributors; n++) + { + float out_center_of_in; // Center of the current out pixel in the in pixel space + int out_first_pixel, out_last_pixel; + int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio); + + stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in); + + stbir__calculate_coefficients_downsample(stbir_info, filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); + } + + stbir__normalize_downsample_coefficients(stbir_info, contributors, coefficients, filter, scale_ratio, shift, input_size, output_size); + } +} + +static float* stbir__get_decode_buffer(stbir__info* stbir_info) +{ + // The 0 index of the decode buffer starts after the margin. This makes + // it okay to use negative indexes on the decode buffer. + return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels]; +} + +#define STBIR__DECODE(type, colorspace) ((type) * (STBIR_MAX_COLORSPACES) + (colorspace)) + +static void stbir__decode_scanline(stbir__info* stbir_info, int n) +{ + int c; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int input_w = stbir_info->input_w; + int input_stride_bytes = stbir_info->input_stride_bytes; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir_edge edge_horizontal = stbir_info->edge_horizontal; + stbir_edge edge_vertical = stbir_info->edge_vertical; + int in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes; + const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset; + int max_x = input_w + stbir_info->horizontal_filter_pixel_margin; + int decode = STBIR__DECODE(type, colorspace); + + int x = -stbir_info->horizontal_filter_pixel_margin; + + // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input, + // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO + if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h)) + { + for (; x < max_x; x++) + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + return; + } + + switch (decode) + { + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / 255; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]]; + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / 65535; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / 65535); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / 65535; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / 4294967295); + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / 4294967295)); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / 4294967295); + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c]; + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel]; + } + + break; + + default: + STBIR__UNIMPLEMENTED("Unknown type/colorspace/channels combination."); + break; + } + + if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED)) + { + for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++) + { + int decode_pixel_index = x * channels; + + // If the alpha value is 0 it will clobber the color values. Make sure it's not. + float alpha = decode_buffer[decode_pixel_index + alpha_channel]; +#ifndef STBIR_NO_ALPHA_EPSILON + if (stbir_info->type != STBIR_TYPE_FLOAT) { + alpha += STBIR_ALPHA_EPSILON; + decode_buffer[decode_pixel_index + alpha_channel] = alpha; + } +#endif + for (c = 0; c < channels; c++) + { + if (c == alpha_channel) + continue; + + decode_buffer[decode_pixel_index + c] *= alpha; + } + } + } + + if (edge_horizontal == STBIR_EDGE_ZERO) + { + for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++) + { + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + } + for (x = input_w; x < max_x; x++) + { + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + } + } +} + +static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length) +{ + return &ring_buffer[index * ring_buffer_length]; +} + +static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n) +{ + int ring_buffer_index; + float* ring_buffer; + + if (stbir_info->ring_buffer_begin_index < 0) + { + ring_buffer_index = stbir_info->ring_buffer_begin_index = 0; + stbir_info->ring_buffer_first_scanline = n; + } + else + { + ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline) + 1) % stbir_info->vertical_filter_pixel_width; + STBIR__DEBUG_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index); + } + + ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float)); + memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes); + + stbir_info->ring_buffer_last_scanline = n; + + return ring_buffer; +} + + +static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, int n, float* output_buffer) +{ + int x, k; + int output_w = stbir_info->output_w; + //int kernel_pixel_width = stbir_info->horizontal_filter_pixel_width; + int channels = stbir_info->channels; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; + float* horizontal_coefficients = stbir_info->horizontal_coefficients; + int coefficient_width = stbir_info->horizontal_coefficient_width; + + for (x = 0; x < output_w; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int out_pixel_index = x * channels; + int coefficient_group = coefficient_width * x; + int coefficient_counter = 0; + + STBIR__DEBUG_ASSERT(n1 >= n0); + STBIR__DEBUG_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin); + STBIR__DEBUG_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin); + STBIR__DEBUG_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); + STBIR__DEBUG_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); + + switch (channels) { + case 1: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 1; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + } + break; + case 2: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 2; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + } + break; + case 3: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 3; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + } + break; + case 4: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 4; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; + } + break; + default: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * channels; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + int c; + STBIR__DEBUG_ASSERT(coefficient != 0); + for (c = 0; c < channels; c++) + output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; + } + break; + } + } +} + +static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, int n, float* output_buffer) +{ + int x, k; + int input_w = stbir_info->input_w; + //int output_w = stbir_info->output_w; + //int kernel_pixel_width = stbir_info->horizontal_filter_pixel_width; + int channels = stbir_info->channels; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; + float* horizontal_coefficients = stbir_info->horizontal_coefficients; + int coefficient_width = stbir_info->horizontal_coefficient_width; + int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin; + int max_x = input_w + filter_pixel_margin * 2; + + STBIR__DEBUG_ASSERT(!stbir__use_width_upsampling(stbir_info)); + + switch (channels) { + case 1: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 1; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 1; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + } + } + break; + + case 2: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 2; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 2; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + } + } + break; + + case 3: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 3; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 3; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + } + } + break; + + case 4: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 4; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 4; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR__DEBUG_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; + } + } + break; + + default: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * channels; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int c; + int out_pixel_index = k * channels; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR__DEBUG_ASSERT(coefficient != 0); + for (c = 0; c < channels; c++) + output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; + } + } + break; + } +} + +static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n) +{ + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, n); + + // Now resample it into the ring buffer. + if (stbir__use_width_upsampling(stbir_info)) + stbir__resample_horizontal_upsample(stbir_info, n, stbir__add_empty_ring_buffer_entry(stbir_info, n)); + else + stbir__resample_horizontal_downsample(stbir_info, n, stbir__add_empty_ring_buffer_entry(stbir_info, n)); + + // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. +} + +static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n) +{ + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, n); + + memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float)); + + // Now resample it into the horizontal buffer. + if (stbir__use_width_upsampling(stbir_info)) + stbir__resample_horizontal_upsample(stbir_info, n, stbir_info->horizontal_buffer); + else + stbir__resample_horizontal_downsample(stbir_info, n, stbir_info->horizontal_buffer); + + // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers. +} + +// Get the specified scan line from the ring buffer. +static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_size, int ring_buffer_length) +{ + int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_size; + return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length); +} + + +static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode) +{ + int x; + int n; + int num_nonalpha; + stbir_uint16 nonalpha[STBIR_MAX_CHANNELS]; + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) + { + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + float alpha = encode_buffer[pixel_index + alpha_channel]; + float reciprocal_alpha = alpha ? 1.0f / alpha : 0; + + // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb + for (n = 0; n < channels; n++) + if (n != alpha_channel) + encode_buffer[pixel_index + n] *= reciprocal_alpha; + + // We added in a small epsilon to prevent the color channel from being deleted with zero alpha. + // Because we only add it for integer types, it will automatically be discarded on integer + // conversion, so we don't need to subtract it back out (which would be problematic for + // numeric precision reasons). + } + } + + // build a table of all channels that need colorspace correction, so + // we don't perform colorspace correction on channels that don't need it. + for (x=0, num_nonalpha=0; x < channels; ++x) + if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) + nonalpha[num_nonalpha++] = (stbir_uint16)x; + + #define STBIR__ROUND_INT(f) ((int) ((f)+0.5)) + #define STBIR__ROUND_UINT(f) ((stbir_uint32) ((f)+0.5)) + + #ifdef STBIR__SATURATE_INT + #define STBIR__ENCODE_LINEAR8(f) stbir__saturate8 (STBIR__ROUND_INT((f) * 255 )) + #define STBIR__ENCODE_LINEAR16(f) stbir__saturate16(STBIR__ROUND_INT((f) * 65535)) + #else + #define STBIR__ENCODE_LINEAR8(f) (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * 255 ) + #define STBIR__ENCODE_LINEAR16(f) (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * 65535) + #endif + + switch (decode) + { + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]); + } + + if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]); + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * 65535); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]); + } + + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * 4294967295); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * 4294967295); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * 4294967295); + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((float*)output_buffer)[index] = encode_buffer[index]; + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel]; + } + break; + + default: + STBIR__UNIMPLEMENTED("Unknown type/colorspace/channels combination."); + break; + } +} + +static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n, int in_first_scanline, int in_last_scanline, float in_center_of_out) +{ + int x, k; + int output_w = stbir_info->output_w; + stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; + float* vertical_coefficients = stbir_info->vertical_coefficients; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int kernel_pixel_width = stbir_info->vertical_filter_pixel_width; + void* output_data = stbir_info->output_data; + float* encode_buffer = stbir_info->encode_buffer; + int decode = STBIR__DECODE(type, colorspace); + int coefficient_width = stbir_info->vertical_coefficient_width; + int coefficient_counter; + int contributor = n; + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; + int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; + //int ring_buffer_last_scanline = stbir_info->ring_buffer_last_scanline; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + + int n0,n1, output_row_start; + int coefficient_group = coefficient_width * contributor; + + n0 = vertical_contributors[contributor].n0; + n1 = vertical_contributors[contributor].n1; + + output_row_start = n * stbir_info->output_stride_bytes; + + STBIR__DEBUG_ASSERT(stbir__use_height_upsampling(stbir_info)); + + memset(encode_buffer, 0, output_w * sizeof(float) * channels); + + // I tried reblocking this for better cache usage of encode_buffer + // (using x_outer, k, x_inner), but it lost speed. -- stb + + coefficient_counter = 0; + switch (channels) { + case 1: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 1; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + } + } + break; + case 2: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 2; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + } + } + break; + case 3: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 3; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; + } + } + break; + case 4: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 4; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; + encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient; + } + } + break; + default: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * channels; + int c; + for (c = 0; c < channels; c++) + encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient; + } + } + break; + } + stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode); +} + +static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n, int in_first_scanline, int in_last_scanline, float in_center_of_out) +{ + int x, k; + int output_w = stbir_info->output_w; + //int output_h = stbir_info->output_h; + stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; + float* vertical_coefficients = stbir_info->vertical_coefficients; + int channels = stbir_info->channels; + int kernel_pixel_width = stbir_info->vertical_filter_pixel_width; + //void* output_data = stbir_info->output_data; + float* horizontal_buffer = stbir_info->horizontal_buffer; + int coefficient_width = stbir_info->vertical_coefficient_width; + int contributor = n + stbir_info->vertical_filter_pixel_margin; + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; + int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; + //int ring_buffer_last_scanline = stbir_info->ring_buffer_last_scanline; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + int n0,n1; + + n0 = vertical_contributors[contributor].n0; + n1 = vertical_contributors[contributor].n1; + + STBIR__DEBUG_ASSERT(!stbir__use_height_upsampling(stbir_info)); + + for (k = n0; k <= n1; k++) + { + int coefficient_index = k - n0; + int coefficient_group = coefficient_width * contributor; + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_pixel_width, ring_buffer_length); + + switch (channels) { + case 1: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 1; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + } + break; + case 2: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 2; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + } + break; + case 3: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 3; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; + } + break; + case 4: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 4; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; + ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient; + } + break; + default: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * channels; + + int c; + for (c = 0; c < channels; c++) + ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient; + } + break; + } + } +} + +static void stbir__buffer_loop_upsample(stbir__info* stbir_info) +{ + int y; + float scale_ratio = stbir_info->vertical_scale; + float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio; + + STBIR__DEBUG_ASSERT(stbir__use_height_upsampling(stbir_info)); + + for (y = 0; y < stbir_info->output_h; y++) + { + float in_center_of_out = 0; // Center of the current out scanline in the in scanline space + int in_first_scanline = 0, in_last_scanline = 0; + + stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out); + + STBIR__DEBUG_ASSERT(in_last_scanline - in_first_scanline <= stbir_info->vertical_filter_pixel_width); + + if (stbir_info->ring_buffer_begin_index >= 0) + { + // Get rid of whatever we don't need anymore. + while (in_first_scanline > stbir_info->ring_buffer_first_scanline) + { + if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) + { + // We just popped the last scanline off the ring buffer. + // Reset it to the empty state. + stbir_info->ring_buffer_begin_index = -1; + stbir_info->ring_buffer_first_scanline = 0; + stbir_info->ring_buffer_last_scanline = 0; + break; + } + else + { + stbir_info->ring_buffer_first_scanline++; + stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->vertical_filter_pixel_width; + } + } + } + + // Load in new ones. + if (stbir_info->ring_buffer_begin_index < 0) + stbir__decode_and_resample_upsample(stbir_info, in_first_scanline); + + while (in_last_scanline > stbir_info->ring_buffer_last_scanline) + stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1); + + // Now all buffers should be ready to write a row of vertical sampling. + stbir__resample_vertical_upsample(stbir_info, y, in_first_scanline, in_last_scanline, in_center_of_out); + + STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h); + } +} + +static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline) +{ + int output_stride_bytes = stbir_info->output_stride_bytes; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int output_w = stbir_info->output_w; + void* output_data = stbir_info->output_data; + int decode = STBIR__DECODE(type, colorspace); + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + + if (stbir_info->ring_buffer_begin_index >= 0) + { + // Get rid of whatever we don't need anymore. + while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline) + { + if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h) + { + int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes; + float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length); + stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode); + STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h); + } + + if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) + { + // We just popped the last scanline off the ring buffer. + // Reset it to the empty state. + stbir_info->ring_buffer_begin_index = -1; + stbir_info->ring_buffer_first_scanline = 0; + stbir_info->ring_buffer_last_scanline = 0; + break; + } + else + { + stbir_info->ring_buffer_first_scanline++; + stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->vertical_filter_pixel_width; + } + } + } +} + +static void stbir__buffer_loop_downsample(stbir__info* stbir_info) +{ + int y; + float scale_ratio = stbir_info->vertical_scale; + int output_h = stbir_info->output_h; + float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio; + int pixel_margin = stbir_info->vertical_filter_pixel_margin; + int max_y = stbir_info->input_h + pixel_margin; + + STBIR__DEBUG_ASSERT(!stbir__use_height_upsampling(stbir_info)); + + for (y = -pixel_margin; y < max_y; y++) + { + float out_center_of_in; // Center of the current out scanline in the in scanline space + int out_first_scanline, out_last_scanline; + + stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in); + + STBIR__DEBUG_ASSERT(out_last_scanline - out_first_scanline <= stbir_info->vertical_filter_pixel_width); + + if (out_last_scanline < 0 || out_first_scanline >= output_h) + continue; + + stbir__empty_ring_buffer(stbir_info, out_first_scanline); + + stbir__decode_and_resample_downsample(stbir_info, y); + + // Load in new ones. + if (stbir_info->ring_buffer_begin_index < 0) + stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline); + + while (out_last_scanline > stbir_info->ring_buffer_last_scanline) + stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1); + + // Now the horizontal buffer is ready to write to all ring buffer rows. + stbir__resample_vertical_downsample(stbir_info, y, out_first_scanline, out_last_scanline, out_center_of_in); + } + + stbir__empty_ring_buffer(stbir_info, stbir_info->output_h); +} + +static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels) +{ + info->input_w = input_w; + info->input_h = input_h; + info->output_w = output_w; + info->output_h = output_h; + info->channels = channels; +} + +static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform) +{ + info->s0 = s0; + info->t0 = t0; + info->s1 = s1; + info->t1 = t1; + + if (transform) + { + info->horizontal_scale = transform[0]; + info->vertical_scale = transform[1]; + info->horizontal_shift = transform[2]; + info->vertical_shift = transform[3]; + } + else + { + info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0); + info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0); + + info->horizontal_shift = s0 * info->input_w / (s1 - s0); + info->vertical_shift = t0 * info->input_h / (t1 - t0); + } +} + +static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter) +{ + if (h_filter == 0) + h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; + if (v_filter == 0) + v_filter = stbir__use_upsampling(info->vertical_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; + info->horizontal_filter = h_filter; + info->vertical_filter = v_filter; +} + +static stbir_uint32 stbir__calculate_memory(stbir__info *info) +{ + int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); + int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale); + + info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w); + info->vertical_num_contributors = stbir__get_contributors(info->vertical_scale , info->vertical_filter , info->input_h, info->output_h); + + info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors); + info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float); + info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors); + info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float); + info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float); + info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float); + info->ring_buffer_size = info->output_w * info->channels * filter_height * sizeof(float); + info->encode_buffer_size = info->output_w * info->channels * sizeof(float); + + STBIR_ASSERT(info->horizontal_filter != 0); + STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late + STBIR_ASSERT(info->vertical_filter != 0); + STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late + + if (stbir__use_height_upsampling(info)) + // The horizontal buffer is for when we're downsampling the height and we + // can't output the result of sampling the decode buffer directly into the + // ring buffers. + info->horizontal_buffer_size = 0; + else + // The encode buffer is to retain precision in the height upsampling method + // and isn't used when height downsampling. + info->encode_buffer_size = 0; + + return info->horizontal_contributors_size + info->horizontal_coefficients_size + + info->vertical_contributors_size + info->vertical_coefficients_size + + info->decode_buffer_size + info->horizontal_buffer_size + + info->ring_buffer_size + info->encode_buffer_size; +} + +static int stbir__resize_allocated(stbir__info *info, + const void* input_data, int input_stride_in_bytes, + void* output_data, int output_stride_in_bytes, + int alpha_channel, stbir_uint32 flags, stbir_datatype type, + stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace, + void* tempmem, size_t tempmem_size_in_bytes) +{ + size_t memory_required = stbir__calculate_memory(info); + + int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type]; + int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type]; + +#ifdef STBIR_DEBUG_OVERWRITE_TEST +#define OVERWRITE_ARRAY_SIZE 8 + unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE]; + + size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type]; + memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE); +#endif + + STBIR_ASSERT(info->channels >= 0); + STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS); + + if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS) + return 0; + + STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + + if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) + return 0; + if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) + return 0; + + if (alpha_channel < 0) + flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED; + + if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) + STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels); + + if (alpha_channel >= info->channels) + return 0; + + STBIR_ASSERT(tempmem); + + if (!tempmem) + return 0; + + STBIR_ASSERT(tempmem_size_in_bytes >= memory_required); + + if (tempmem_size_in_bytes < memory_required) + return 0; + + memset(tempmem, 0, tempmem_size_in_bytes); + + info->input_data = input_data; + info->input_stride_bytes = width_stride_input; + + info->output_data = output_data; + info->output_stride_bytes = width_stride_output; + + info->alpha_channel = alpha_channel; + info->flags = flags; + info->type = type; + info->edge_horizontal = edge_horizontal; + info->edge_vertical = edge_vertical; + info->colorspace = colorspace; + + info->horizontal_coefficient_width = stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); + info->vertical_coefficient_width = stbir__get_coefficient_width (info->vertical_filter , info->vertical_scale ); + info->horizontal_filter_pixel_width = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale); + info->vertical_filter_pixel_width = stbir__get_filter_pixel_width (info->vertical_filter , info->vertical_scale ); + info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); + info->vertical_filter_pixel_margin = stbir__get_filter_pixel_margin(info->vertical_filter , info->vertical_scale ); + + info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float); + info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2; + +#define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size) + + info->horizontal_contributors = (stbir__contributors *) tempmem; + info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float); + info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors); + info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float); + info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float); + + if (stbir__use_height_upsampling(info)) + { + info->horizontal_buffer = NULL; + info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); + info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float); + + STBIR__DEBUG_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); + } + else + { + info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); + info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float); + info->encode_buffer = NULL; + + STBIR__DEBUG_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); + } + +#undef STBIR__NEXT_MEMPTR + + // This signals that the ring buffer is empty + info->ring_buffer_begin_index = -1; + + stbir__calculate_filters(info, info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w); + stbir__calculate_filters(info, info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h); + + STBIR_PROGRESS_REPORT(0); + + if (stbir__use_height_upsampling(info)) + stbir__buffer_loop_upsample(info); + else + stbir__buffer_loop_downsample(info); + + STBIR_PROGRESS_REPORT(1); + +#ifdef STBIR_DEBUG_OVERWRITE_TEST + STBIR__DEBUG_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); + STBIR__DEBUG_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0); + STBIR__DEBUG_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); + STBIR__DEBUG_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0); +#endif + + return 1; +} + + +static int stbir__resize_arbitrary( + void *alloc_context, + const void* input_data, int input_w, int input_h, int input_stride_in_bytes, + void* output_data, int output_w, int output_h, int output_stride_in_bytes, + float s0, float t0, float s1, float t1, float *transform, + int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type, + stbir_filter h_filter, stbir_filter v_filter, + stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace) +{ + stbir__info info; + int result; + size_t memory_required; + void* extra_memory; + + stbir__setup(&info, input_w, input_h, output_w, output_h, channels); + stbir__calculate_transform(&info, s0,t0,s1,t1,transform); + stbir__choose_filter(&info, h_filter, v_filter); + memory_required = stbir__calculate_memory(&info); + extra_memory = STBIR_MALLOC(memory_required, alloc_context); + + if (!extra_memory) + return 0; + + result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes, + output_data, output_stride_in_bytes, + alpha_channel, flags, type, + edge_horizontal, edge_vertical, + colorspace, extra_memory, memory_required); + + STBIR_FREE(extra_memory, alloc_context); + + return result; +} + +STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); +} + +STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); +} + +STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB); +} + +STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB); +} + +STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + +STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + + +STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + + +STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + + +STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float x_scale, float y_scale, + float x_offset, float y_offset) +{ + float transform[4]; + transform[0] = x_scale; + transform[1] = y_scale; + transform[2] = x_offset; + transform[3] = y_offset; + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + +STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float s0, float t0, float s1, float t1) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + +#endif // STB_IMAGE_RESIZE_IMPLEMENTATION diff --git a/foreign/stb_image_write.h b/foreign/stb_image_write.h new file mode 100644 index 0000000..ecc285f --- /dev/null +++ b/foreign/stb_image_write.h @@ -0,0 +1,993 @@ +/* stb_image_write - v1.00 - public domain - http://nothings.org/stb/stb_image_write.h + writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010-2015 + no warranty implied; use at your own risk + + Before #including, + + #define STB_IMAGE_WRITE_IMPLEMENTATION + + in the file that you want to have the implementation. + + Will probably not work correctly with strict-aliasing optimizations. + +ABOUT: + + This header file is a library for writing images to C stdio. It could be + adapted to write to memory or a general streaming interface; let me know. + + The PNG output is not optimal; it is 20-50% larger than the file + written by a decent optimizing implementation. This library is designed + for source code compactness and simplicity, not optimal image file size + or run-time performance. + +BUILDING: + + You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. + You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace + malloc,realloc,free. + You can define STBIW_MEMMOVE() to replace memmove() + +USAGE: + + There are four functions, one for each image file format: + + int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); + int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_hdr(char const *filename, int w, int h, int comp, const void *data); + + There are also four equivalent functions that use an arbitrary write function. You are + expected to open/close your file-equivalent before and after calling these: + + int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); + int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); + int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); + int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); + + where the callback is: + void stbi_write_func(void *context, void *data, int size); + + You can define STBI_WRITE_NO_STDIO to disable the file variant of these + functions, so the library will not use stdio.h at all. However, this will + also disable HDR writing, because it requires stdio for formatted output. + + Each function returns 0 on failure and non-0 on success. + + The functions create an image file defined by the parameters. The image + is a rectangle of pixels stored from left-to-right, top-to-bottom. + Each pixel contains 'comp' channels of data stored interleaved with 8-bits + per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is + monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. + The *data pointer points to the first byte of the top-left-most pixel. + For PNG, "stride_in_bytes" is the distance in bytes from the first byte of + a row of pixels to the first byte of the next row of pixels. + + PNG creates output files with the same number of components as the input. + The BMP format expands Y to RGB in the file format and does not + output alpha. + + PNG supports writing rectangles of data even when the bytes storing rows of + data are not consecutive in memory (e.g. sub-rectangles of a larger image), + by supplying the stride between the beginning of adjacent rows. The other + formats do not. (Thus you cannot write a native-format BMP through the BMP + writer, both because it is in BGR order and because it may have padding + at the end of the line.) + + HDR expects linear float data. Since the format is always 32-bit rgb(e) + data, alpha (if provided) is discarded, and for monochrome data it is + replicated across all three channels. + + TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed + data, set the global variable 'stbi_write_tga_with_rle' to 0. + +CREDITS: + + PNG/BMP/TGA + Sean Barrett + HDR + Baldur Karlsson + TGA monochrome: + Jean-Sebastien Guay + misc enhancements: + Tim Kelsey + TGA RLE + Alan Hickman + initial file IO callback implementation + Emmanuel Julien + bugfixes: + github:Chribba + Guillaume Chereau + github:jry2 + +LICENSE + +This software is in the public domain. Where that dedication is not +recognized, you are granted a perpetual, irrevocable license to copy, +distribute, and modify this file as you see fit. + +*/ + +#ifndef INCLUDE_STB_IMAGE_WRITE_H +#define INCLUDE_STB_IMAGE_WRITE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef STB_IMAGE_WRITE_STATIC +#define STBIWDEF static +#else +#define STBIWDEF extern +extern int stbi_write_tga_with_rle; +#endif + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); +#endif + +typedef void stbi_write_func(void *context, void *data, int size); + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); + +#ifdef __cplusplus +} +#endif + +#endif//INCLUDE_STB_IMAGE_WRITE_H + +#ifdef STB_IMAGE_WRITE_IMPLEMENTATION + +#ifdef _WIN32 + #define _CRT_SECURE_NO_WARNINGS + #define _CRT_NONSTDC_NO_DEPRECATE +#endif + +#ifndef STBI_WRITE_NO_STDIO +#include <stdio.h> +#endif // STBI_WRITE_NO_STDIO + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && defined(STBIW_REALLOC) +// ok +#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) +// ok +#else +#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC." +#endif + +#ifndef STBIW_MALLOC +#define STBIW_MALLOC(sz) malloc(sz) +#define STBIW_REALLOC(p,sz) realloc(p,sz) +#define STBIW_FREE(p) free(p) +#endif +#ifndef STBIW_MEMMOVE +#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) +#endif + + +#ifndef STBIW_ASSERT +#include <assert.h> +#define STBIW_ASSERT(x) assert(x) +#endif + +typedef struct +{ + stbi_write_func *func; + void *context; +} stbi__write_context; + +// initialize a callback-based context +static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) +{ + s->func = c; + s->context = context; +} + +#ifndef STBI_WRITE_NO_STDIO + +static void stbi__stdio_write(void *context, void *data, int size) +{ + fwrite(data,1,size,(FILE*) context); +} + +static int stbi__start_write_file(stbi__write_context *s, const char *filename) +{ + FILE *f = fopen(filename, "wb"); + stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); + return f != NULL; +} + +static void stbi__end_write_file(stbi__write_context *s) +{ + fclose((FILE *)s->context); +} + +#endif // !STBI_WRITE_NO_STDIO + +typedef unsigned int stbiw_uint32; +typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; + +#ifdef STB_IMAGE_WRITE_STATIC +static int stbi_write_tga_with_rle = 1; +#else +int stbi_write_tga_with_rle = 1; +#endif + +static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) +{ + while (*fmt) { + switch (*fmt++) { + case ' ': break; + case '1': { unsigned char x = (unsigned char) va_arg(v, int); + s->func(s->context,&x,1); + break; } + case '2': { int x = va_arg(v,int); + unsigned char b[2]; + b[0] = (unsigned char) x; + b[1] = (unsigned char) (x>>8); + s->func(s->context,b,2); + break; } + case '4': { stbiw_uint32 x = va_arg(v,int); + unsigned char b[4]; + b[0]=(unsigned char)x; + b[1]=(unsigned char)(x>>8); + b[2]=(unsigned char)(x>>16); + b[3]=(unsigned char)(x>>24); + s->func(s->context,b,4); + break; } + default: + STBIW_ASSERT(0); + return; + } + } +} + +static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) +{ + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); +} + +static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) +{ + unsigned char arr[3]; + arr[0] = a, arr[1] = b, arr[2] = c; + s->func(s->context, arr, 3); +} + +static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) +{ + unsigned char bg[3] = { 255, 0, 255}, px[3]; + int k; + + if (write_alpha < 0) + s->func(s->context, &d[comp - 1], 1); + + switch (comp) { + case 1: + s->func(s->context,d,1); + break; + case 2: + if (expand_mono) + stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp + else + s->func(s->context, d, 1); // monochrome TGA + break; + case 4: + if (!write_alpha) { + // composite against pink background + for (k = 0; k < 3; ++k) + px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; + stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); + break; + } + /* FALLTHROUGH */ + case 3: + stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); + break; + } + if (write_alpha > 0) + s->func(s->context, &d[comp - 1], 1); +} + +static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) +{ + stbiw_uint32 zero = 0; + int i,j, j_end; + + if (y <= 0) + return; + + if (vdir < 0) + j_end = -1, j = y-1; + else + j_end = y, j = 0; + + for (; j != j_end; j += vdir) { + for (i=0; i < x; ++i) { + unsigned char *d = (unsigned char *) data + (j*x+i)*comp; + stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); + } + s->func(s->context, &zero, scanline_pad); + } +} + +static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) +{ + if (y < 0 || x < 0) { + return 0; + } else { + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); + stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); + return 1; + } +} + +static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) +{ + int pad = (-x*3) & 3; + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, + "11 4 22 4" "4 44 22 444444", + 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header + 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header +} + +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_bmp_core(&s, x, y, comp, data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_bmp_core(&s, x, y, comp, data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif //!STBI_WRITE_NO_STDIO + +static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) +{ + int has_alpha = (comp == 2 || comp == 4); + int colorbytes = has_alpha ? comp-1 : comp; + int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 + + if (y < 0 || x < 0) + return 0; + + if (!stbi_write_tga_with_rle) { + return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, + "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); + } else { + int i,j,k; + + stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); + + for (j = y - 1; j >= 0; --j) { + unsigned char *row = (unsigned char *) data + j * x * comp; + int len; + + for (i = 0; i < x; i += len) { + unsigned char *begin = row + i * comp; + int diff = 1; + len = 1; + + if (i < x - 1) { + ++len; + diff = memcmp(begin, row + (i + 1) * comp, comp); + if (diff) { + const unsigned char *prev = begin; + for (k = i + 2; k < x && len < 128; ++k) { + if (memcmp(prev, row + k * comp, comp)) { + prev += comp; + ++len; + } else { + --len; + break; + } + } + } else { + for (k = i + 2; k < x && len < 128; ++k) { + if (!memcmp(begin, row + k * comp, comp)) { + ++len; + } else { + break; + } + } + } + } + + if (diff) { + unsigned char header = (unsigned char) (len - 1); + s->func(s->context, &header, 1); + for (k = 0; k < len; ++k) { + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); + } + } else { + unsigned char header = (unsigned char) (len - 129); + s->func(s->context, &header, 1); + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); + } + } + } + } + return 1; +} + +int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_tga_core(&s, x, y, comp, (void *) data); +} + +#ifndef STBI_WRITE_NO_STDIO +int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR writer +// by Baldur Karlsson +#ifndef STBI_WRITE_NO_STDIO + +#define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) + +void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) +{ + int exponent; + float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); + + if (maxcomp < 1e-32) { + rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; + } else { + float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; + + rgbe[0] = (unsigned char)(linear[0] * normalize); + rgbe[1] = (unsigned char)(linear[1] * normalize); + rgbe[2] = (unsigned char)(linear[2] * normalize); + rgbe[3] = (unsigned char)(exponent + 128); + } +} + +void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) +{ + unsigned char lengthbyte = (unsigned char) (length+128); + STBIW_ASSERT(length+128 <= 255); + s->func(s->context, &lengthbyte, 1); + s->func(s->context, &databyte, 1); +} + +void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) +{ + unsigned char lengthbyte = (unsigned char )(length & 0xff); + STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code + s->func(s->context, &lengthbyte, 1); + s->func(s->context, data, length); +} + +void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) +{ + unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; + unsigned char rgbe[4]; + float linear[3]; + int x; + + scanlineheader[2] = (width&0xff00)>>8; + scanlineheader[3] = (width&0x00ff); + + /* skip RLE for images too small or large */ + if (width < 8 || width >= 32768) { + for (x=0; x < width; x++) { + switch (ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + s->func(s->context, rgbe, 4); + } + } else { + int c,r; + /* encode into scratch buffer */ + for (x=0; x < width; x++) { + switch(ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + scratch[x + width*0] = rgbe[0]; + scratch[x + width*1] = rgbe[1]; + scratch[x + width*2] = rgbe[2]; + scratch[x + width*3] = rgbe[3]; + } + + s->func(s->context, scanlineheader, 4); + + /* RLE each component separately */ + for (c=0; c < 4; c++) { + unsigned char *comp = &scratch[width*c]; + + x = 0; + while (x < width) { + // find first run + r = x; + while (r+2 < width) { + if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) + break; + ++r; + } + if (r+2 >= width) + r = width; + // dump up to first run + while (x < r) { + int len = r-x; + if (len > 128) len = 128; + stbiw__write_dump_data(s, len, &comp[x]); + x += len; + } + // if there's a run, output it + if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd + // find next byte after run + while (r < width && comp[r] == comp[x]) + ++r; + // output run up to r + while (x < r) { + int len = r-x; + if (len > 127) len = 127; + stbiw__write_run_data(s, len, comp[x]); + x += len; + } + } + } + } + } +} + +static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) +{ + if (y <= 0 || x <= 0 || data == NULL) + return 0; + else { + // Each component is stored separately. Allocate scratch space for full output scanline. + unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); + int i, len; + char buffer[128]; + char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; + s->func(s->context, header, sizeof(header)-1); + + len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); + s->func(s->context, buffer, len); + + for(i=0; i < y; i++) + stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*i*x); + STBIW_FREE(scratch); + return 1; + } +} + +int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_hdr_core(&s, x, y, comp, (float *) data); +} + +int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif // STBI_WRITE_NO_STDIO + + +////////////////////////////////////////////////////////////////////////////// +// +// PNG writer +// + +// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() +#define stbiw__sbraw(a) ((int *) (a) - 2) +#define stbiw__sbm(a) stbiw__sbraw(a)[0] +#define stbiw__sbn(a) stbiw__sbraw(a)[1] + +#define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) +#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) +#define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) + +#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) +#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) +#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) + +static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) +{ + int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; + void *p = STBIW_REALLOC(*arr ? stbiw__sbraw(*arr) : 0, itemsize * m + sizeof(int)*2); + STBIW_ASSERT(p); + if (p) { + if (!*arr) ((int *) p)[1] = 0; + *arr = (void *) ((int *) p + 2); + stbiw__sbm(*arr) = m; + } + return *arr; +} + +static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) +{ + while (*bitcount >= 8) { + stbiw__sbpush(data, (unsigned char) *bitbuffer); + *bitbuffer >>= 8; + *bitcount -= 8; + } + return data; +} + +static int stbiw__zlib_bitrev(int code, int codebits) +{ + int res=0; + while (codebits--) { + res = (res << 1) | (code & 1); + code >>= 1; + } + return res; +} + +static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) +{ + int i; + for (i=0; i < limit && i < 258; ++i) + if (a[i] != b[i]) break; + return i; +} + +static unsigned int stbiw__zhash(unsigned char *data) +{ + stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + return hash; +} + +#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) +#define stbiw__zlib_add(code,codebits) \ + (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) +#define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) +// default huffman tables +#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) +#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) +#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) +#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) +#define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) +#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) + +#define stbiw__ZHASH 16384 + +unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) +{ + static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; + static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; + static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; + static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; + unsigned int bitbuf=0; + int i,j, bitcount=0; + unsigned char *out = NULL; + unsigned char **hash_table[stbiw__ZHASH]; // 64KB on the stack! + if (quality < 5) quality = 5; + + stbiw__sbpush(out, 0x78); // DEFLATE 32K window + stbiw__sbpush(out, 0x5e); // FLEVEL = 1 + stbiw__zlib_add(1,1); // BFINAL = 1 + stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman + + for (i=0; i < stbiw__ZHASH; ++i) + hash_table[i] = NULL; + + i=0; + while (i < data_len-3) { + // hash next 3 bytes of data to be compressed + int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; + unsigned char *bestloc = 0; + unsigned char **hlist = hash_table[h]; + int n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32768) { // if entry lies within window + int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); + if (d >= best) best=d,bestloc=hlist[j]; + } + } + // when hash table entry is too long, delete half the entries + if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { + STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); + stbiw__sbn(hash_table[h]) = quality; + } + stbiw__sbpush(hash_table[h],data+i); + + if (bestloc) { + // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal + h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); + hlist = hash_table[h]; + n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32767) { + int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); + if (e > best) { // if next match is better, bail on current match + bestloc = NULL; + break; + } + } + } + } + + if (bestloc) { + int d = (int) (data+i - bestloc); // distance back + STBIW_ASSERT(d <= 32767 && best <= 258); + for (j=0; best > lengthc[j+1]-1; ++j); + stbiw__zlib_huff(j+257); + if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); + for (j=0; d > distc[j+1]-1; ++j); + stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); + if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); + i += best; + } else { + stbiw__zlib_huffb(data[i]); + ++i; + } + } + // write out final bytes + for (;i < data_len; ++i) + stbiw__zlib_huffb(data[i]); + stbiw__zlib_huff(256); // end of block + // pad with 0 bits to byte boundary + while (bitcount) + stbiw__zlib_add(0,1); + + for (i=0; i < stbiw__ZHASH; ++i) + (void) stbiw__sbfree(hash_table[i]); + + { + // compute adler32 on input + unsigned int s1=1, s2=0; + int blocklen = (int) (data_len % 5552); + j=0; + while (j < data_len) { + for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1; + s1 %= 65521, s2 %= 65521; + j += blocklen; + blocklen = 5552; + } + stbiw__sbpush(out, (unsigned char) (s2 >> 8)); + stbiw__sbpush(out, (unsigned char) s2); + stbiw__sbpush(out, (unsigned char) (s1 >> 8)); + stbiw__sbpush(out, (unsigned char) s1); + } + *out_len = stbiw__sbn(out); + // make returned pointer freeable + STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); + return (unsigned char *) stbiw__sbraw(out); +} + +unsigned int stbiw__crc32(unsigned char *buffer, int len) +{ + static unsigned int crc_table[256]; + unsigned int crc = ~0u; + int i,j; + if (crc_table[1] == 0) + for(i=0; i < 256; i++) + for (crc_table[i]=i, j=0; j < 8; ++j) + crc_table[i] = (crc_table[i] >> 1) ^ (crc_table[i] & 1 ? 0xedb88320 : 0); + for (i=0; i < len; ++i) + crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; + return ~crc; +} + +#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=(unsigned char)(a),(o)[1]=(unsigned char)(b),(o)[2]=(unsigned char)(c),(o)[3]=(unsigned char)(d),(o)+=4) +#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); +#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) + +static void stbiw__wpcrc(unsigned char **data, int len) +{ + unsigned int crc = stbiw__crc32(*data - len - 4, len+4); + stbiw__wp32(*data, crc); +} + +static unsigned char stbiw__paeth(int a, int b, int c) +{ + int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); + if (pa <= pb && pa <= pc) return (unsigned char) a; + if (pb <= pc) return (unsigned char) b; + return (unsigned char) c; +} + +unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) +{ + int ctype[5] = { -1, 0, 4, 2, 6 }; + unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; + unsigned char *out,*o, *filt, *zlib; + signed char *line_buffer; + int i,j,k,p,zlen; + + if (stride_bytes == 0) + stride_bytes = x * n; + + filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; + line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } + for (j=0; j < y; ++j) { + static int mapping[] = { 0,1,2,3,4 }; + static int firstmap[] = { 0,1,0,5,6 }; + int *mymap = j ? mapping : firstmap; + int best = 0, bestval = 0x7fffffff; + for (p=0; p < 2; ++p) { + for (k= p?best:0; k < 5; ++k) { + int type = mymap[k],est=0; + unsigned char *z = pixels + stride_bytes*j; + for (i=0; i < n; ++i) + switch (type) { + case 0: line_buffer[i] = z[i]; break; + case 1: line_buffer[i] = z[i]; break; + case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; + case 3: line_buffer[i] = z[i] - (z[i-stride_bytes]>>1); break; + case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-stride_bytes],0)); break; + case 5: line_buffer[i] = z[i]; break; + case 6: line_buffer[i] = z[i]; break; + } + for (i=n; i < x*n; ++i) { + switch (type) { + case 0: line_buffer[i] = z[i]; break; + case 1: line_buffer[i] = z[i] - z[i-n]; break; + case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; + case 3: line_buffer[i] = z[i] - ((z[i-n] + z[i-stride_bytes])>>1); break; + case 4: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-stride_bytes], z[i-stride_bytes-n]); break; + case 5: line_buffer[i] = z[i] - (z[i-n]>>1); break; + case 6: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; + } + } + if (p) break; + for (i=0; i < x*n; ++i) + est += abs((signed char) line_buffer[i]); + if (est < bestval) { bestval = est; best = k; } + } + } + // when we get here, best contains the filter type, and line_buffer contains the data + filt[j*(x*n+1)] = (unsigned char) best; + STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); + } + STBIW_FREE(line_buffer); + zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, 8); // increase 8 to get smaller but use more memory + STBIW_FREE(filt); + if (!zlib) return 0; + + // each tag requires 12 bytes of overhead + out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); + if (!out) return 0; + *out_len = 8 + 12+13 + 12+zlen + 12; + + o=out; + STBIW_MEMMOVE(o,sig,8); o+= 8; + stbiw__wp32(o, 13); // header length + stbiw__wptag(o, "IHDR"); + stbiw__wp32(o, x); + stbiw__wp32(o, y); + *o++ = 8; + *o++ = (unsigned char) ctype[n]; + *o++ = 0; + *o++ = 0; + *o++ = 0; + stbiw__wpcrc(&o,13); + + stbiw__wp32(o, zlen); + stbiw__wptag(o, "IDAT"); + STBIW_MEMMOVE(o, zlib, zlen); + o += zlen; + STBIW_FREE(zlib); + stbiw__wpcrc(&o, zlen); + + stbiw__wp32(o,0); + stbiw__wptag(o, "IEND"); + stbiw__wpcrc(&o,0); + + STBIW_ASSERT(o == out + *out_len); + + return out; +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) +{ + FILE *f; + int len; + unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); + if (png == NULL) return 0; + f = fopen(filename, "wb"); + if (!f) { STBIW_FREE(png); return 0; } + fwrite(png, 1, len, f); + fclose(f); + STBIW_FREE(png); + return 1; +} +#endif + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) +{ + int len; + unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); + if (png == NULL) return 0; + func(context, png, len); + STBIW_FREE(png); + return 1; +} + +#endif // STB_IMAGE_WRITE_IMPLEMENTATION + +/* Revision history + 1.00 (2015-09-14) + installable file IO function + 0.99 (2015-09-13) + warning fixes; TGA rle support + 0.98 (2015-04-08) + added STBIW_MALLOC, STBIW_ASSERT etc + 0.97 (2015-01-18) + fixed HDR asserts, rewrote HDR rle logic + 0.96 (2015-01-17) + add HDR output + fix monochrome BMP + 0.95 (2014-08-17) + add monochrome TGA output + 0.94 (2014-05-31) + rename private functions to avoid conflicts with stb_image.h + 0.93 (2014-05-27) + warning fixes + 0.92 (2010-08-01) + casts to unsigned char to fix warnings + 0.91 (2010-07-17) + first public release + 0.90 first internal release +*/ diff --git a/foreign/stb_truetype.h b/foreign/stb_truetype.h new file mode 100644 index 0000000..7138f18 --- /dev/null +++ b/foreign/stb_truetype.h @@ -0,0 +1,2666 @@ +// stb_truetype.h - v1.05 - public domain +// authored from 2009-2014 by Sean Barrett / RAD Game Tools +// +// This library processes TrueType files: +// parse files +// extract glyph metrics +// extract glyph shapes +// render glyphs to one-channel bitmaps with antialiasing (box filter) +// +// Todo: +// non-MS cmaps +// crashproof on bad data +// hinting? (no longer patented) +// cleartype-style AA? +// optimize: use simple memory allocator for intermediates +// optimize: build edge-list directly from curves +// optimize: rasterize directly from curves? +// +// CUSTOMIZATIONS +// +// This particular version has been customized by Allen Webster. +// These customizations include: +// stbtt_GetBakedQuadUnrounded +// +// ADDITIONAL CONTRIBUTORS +// +// Mikko Mononen: compound shape support, more cmap formats +// Tor Andersson: kerning, subpixel rendering +// +// Bug/warning reports/fixes: +// "Zer" on mollyrocket (with fix) +// Cass Everitt +// stoiko (Haemimont Games) +// Brian Hook +// Walter van Niftrik +// David Gow +// David Given +// Ivan-Assen Ivanov +// Anthony Pesch +// Johan Duparc +// Hou Qiming +// Fabian "ryg" Giesen +// Martins Mozeiko +// Cap Petschulat +// Omar Cornut +// github:aloucks +// Peter LaValle +// +// Misc other: +// Ryan Gordon +// +// VERSION HISTORY +// +// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC +// 1.04 (2015-04-15) typo in example +// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes +// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ +// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match +// non-oversampled; STBTT_POINT_SIZE for packed case only +// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling +// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) +// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID +// 0.8b (2014-07-07) fix a warning +// 0.8 (2014-05-25) fix a few more warnings +// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back +// 0.6c (2012-07-24) improve documentation +// 0.6b (2012-07-20) fix a few more warnings +// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, +// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty +// 0.5 (2011-12-09) bugfixes: +// subpixel glyph renderer computed wrong bounding box +// first vertex of shape can be off-curve (FreeSans) +// 0.4b (2011-12-03) fixed an error in the font baking example +// 0.4 (2011-12-01) kerning, subpixel rendering (tor) +// bugfixes for: +// codepoint-to-glyph conversion using table fmt=12 +// codepoint-to-glyph conversion using table fmt=4 +// stbtt_GetBakedQuad with non-square texture (Zer) +// updated Hello World! sample to use kerning and subpixel +// fixed some warnings +// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) +// userdata, malloc-from-userdata, non-zero fill (stb) +// 0.2 (2009-03-11) Fix unsigned/signed char warnings +// 0.1 (2009-03-09) First public release +// +// LICENSE +// +// This software is in the public domain. Where that dedication is not +// recognized, you are granted a perpetual, irrevokable license to copy +// and modify this file as you see fit. +// +// USAGE +// +// Include this file in whatever places neeed to refer to it. In ONE C/C++ +// file, write: +// #define STB_TRUETYPE_IMPLEMENTATION +// before the #include of this file. This expands out the actual +// implementation into that C/C++ file. +// +// To make the implementation private to the file that generates the implementation, +// #define STBTT_STATIC +// +// Simple 3D API (don't ship this, but it's fine for tools and quick start) +// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture +// stbtt_GetBakedQuad() -- compute quad to draw for a given char +// +// Improved 3D API (more shippable): +// #include "stb_rect_pack.h" -- optional, but you really want it +// stbtt_PackBegin() +// stbtt_PackSetOversample() -- for improved quality on small fonts +// stbtt_PackFontRanges() +// stbtt_PackEnd() +// stbtt_GetPackedQuad() +// +// "Load" a font file from a memory buffer (you have to keep the buffer loaded) +// stbtt_InitFont() +// stbtt_GetFontOffsetForIndex() -- use for TTC font collections +// +// Render a unicode codepoint to a bitmap +// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap +// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide +// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be +// +// Character advance/positioning +// stbtt_GetCodepointHMetrics() +// stbtt_GetFontVMetrics() +// stbtt_GetCodepointKernAdvance() +// +// ADDITIONAL DOCUMENTATION +// +// Immediately after this block comment are a series of sample programs. +// +// After the sample programs is the "header file" section. This section +// includes documentation for each API function. +// +// Some important concepts to understand to use this library: +// +// Codepoint +// Characters are defined by unicode codepoints, e.g. 65 is +// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is +// the hiragana for "ma". +// +// Glyph +// A visual character shape (every codepoint is rendered as +// some glyph) +// +// Glyph index +// A font-specific integer ID representing a glyph +// +// Baseline +// Glyph shapes are defined relative to a baseline, which is the +// bottom of uppercase characters. Characters extend both above +// and below the baseline. +// +// Current Point +// As you draw text to the screen, you keep track of a "current point" +// which is the origin of each character. The current point's vertical +// position is the baseline. Even "baked fonts" use this model. +// +// Vertical Font Metrics +// The vertical qualities of the font, used to vertically position +// and space the characters. See docs for stbtt_GetFontVMetrics. +// +// Font Size in Pixels or Points +// The preferred interface for specifying font sizes in stb_truetype +// is to specify how tall the font's vertical extent should be in pixels. +// If that sounds good enough, skip the next paragraph. +// +// Most font APIs instead use "points", which are a common typographic +// measurement for describing font size, defined as 72 points per inch. +// stb_truetype provides a point API for compatibility. However, true +// "per inch" conventions don't make much sense on computer displays +// since they different monitors have different number of pixels per +// inch. For example, Windows traditionally uses a convention that +// there are 96 pixels per inch, thus making 'inch' measurements have +// nothing to do with inches, and thus effectively defining a point to +// be 1.333 pixels. Additionally, the TrueType font data provides +// an explicit scale factor to scale a given font's glyphs to points, +// but the author has observed that this scale factor is often wrong +// for non-commercial fonts, thus making fonts scaled in points +// according to the TrueType spec incoherently sized in practice. +// +// ADVANCED USAGE +// +// Quality: +// +// - Use the functions with Subpixel at the end to allow your characters +// to have subpixel positioning. Since the font is anti-aliased, not +// hinted, this is very import for quality. (This is not possible with +// baked fonts.) +// +// - Kerning is now supported, and if you're supporting subpixel rendering +// then kerning is worth using to give your text a polished look. +// +// Performance: +// +// - Convert Unicode codepoints to glyph indexes and operate on the glyphs; +// if you don't do this, stb_truetype is forced to do the conversion on +// every call. +// +// - There are a lot of memory allocations. We should modify it to take +// a temp buffer and allocate from the temp buffer (without freeing), +// should help performance a lot. +// +// NOTES +// +// The system uses the raw data found in the .ttf file without changing it +// and without building auxiliary data structures. This is a bit inefficient +// on little-endian systems (the data is big-endian), but assuming you're +// caching the bitmaps or glyph shapes this shouldn't be a big deal. +// +// It appears to be very hard to programmatically determine what font a +// given file is in a general way. I provide an API for this, but I don't +// recommend it. +// +// +// SOURCE STATISTICS (based on v0.6c, 2050 LOC) +// +// Documentation & header file 520 LOC \___ 660 LOC documentation +// Sample code 140 LOC / +// Truetype parsing 620 LOC ---- 620 LOC TrueType +// Software rasterization 240 LOC \ . +// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation +// Bitmap management 100 LOC / +// Baked bitmap interface 70 LOC / +// Font name matching & access 150 LOC ---- 150 +// C runtime library abstraction 60 LOC ---- 60 + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// SAMPLE PROGRAMS +//// +// +// Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless +// +#if 0 +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +unsigned char ttf_buffer[1<<20]; +unsigned char temp_bitmap[512*512]; + +stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs +GLuint ftex; + +void my_stbtt_initfont(void) +{ + fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb")); + stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits! + // can free ttf_buffer at this point + glGenTextures(1, &ftex); + glBindTexture(GL_TEXTURE_2D, ftex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); + // can free temp_bitmap at this point + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +} + +void my_stbtt_print(float x, float y, char *text) +{ + // assume orthographic projection with units = screen pixels, origin at top left + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, ftex); + glBegin(GL_QUADS); + while (*text) { + if (*text >= 32 && *text < 128) { + stbtt_aligned_quad q; + stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 + glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); + glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); + glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); + glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); + } + ++text; + } + glEnd(); +} +#endif +// +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program (this compiles): get a single bitmap, print as ASCII art +// +#if 0 +#include <stdio.h> +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +char ttf_buffer[1<<25]; + +int main(int argc, char **argv) +{ + stbtt_fontinfo font; + unsigned char *bitmap; + int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); + + fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); + + stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); + bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); + + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) + putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); + putchar('\n'); + } + return 0; +} +#endif +// +// Output: +// +// .ii. +// @@@@@@. +// V@Mio@@o +// :i. V@V +// :oM@@M +// :@@@MM@M +// @@o o@M +// :@@. M@M +// @@@o@@@@ +// :M@@V:@@. +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program: print "Hello World!" banner, with bugs +// +#if 0 +char buffer[24<<20]; +unsigned char screen[20][79]; + +int main(int arg, char **argv) +{ + stbtt_fontinfo font; + int i,j,ascent,baseline,ch=0; + float scale, xpos=2; // leave a little padding in case the character extends left + char *text = "Heljo World!"; + + fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); + stbtt_InitFont(&font, buffer, 0); + + scale = stbtt_ScaleForPixelHeight(&font, 15); + stbtt_GetFontVMetrics(&font, &ascent,0,0); + baseline = (int) (ascent*scale); + + while (text[ch]) { + int advance,lsb,x0,y0,x1,y1; + float x_shift = xpos - (float) floor(xpos); + stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); + stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); + // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong + // because this API is really for baking character bitmaps into textures. if you want to render + // a sequence of characters, you really need to render each bitmap to a temp buffer, then + // "alpha blend" that into the working buffer + xpos += (advance * scale); + if (text[ch+1]) + xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); + ++ch; + } + + for (j=0; j < 20; ++j) { + for (i=0; i < 78; ++i) + putchar(" .:ioVM@"[screen[j][i]>>5]); + putchar('\n'); + } + + return 0; +} +#endif + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// INTEGRATION WITH YOUR CODEBASE +//// +//// The following sections allow you to supply alternate definitions +//// of C library functions used by stb_truetype. + +#ifdef STB_TRUETYPE_IMPLEMENTATION + // #define your own (u)stbtt_int8/16/32 before including to override this + #ifndef stbtt_uint8 + typedef unsigned char stbtt_uint8; + typedef signed char stbtt_int8; + typedef unsigned short stbtt_uint16; + typedef signed short stbtt_int16; + typedef unsigned int stbtt_uint32; + typedef signed int stbtt_int32; + #endif + + typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; + typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; + + // #define your own STBTT_sort() to override this to avoid qsort + #ifndef STBTT_sort + #include <stdlib.h> + #define STBTT_sort(data,num_items,item_size,compare_func) qsort(data,num_items,item_size,compare_func) + #endif + + // #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h + #ifndef STBTT_ifloor + #include <math.h> + #define STBTT_ifloor(x) ((int) floor(x)) + #define STBTT_iceil(x) ((int) ceil(x)) + #endif + + #ifndef STBTT_sqrt + #include <math.h> + #define STBTT_sqrt(x) sqrt(x) + #endif + + // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h + #ifndef STBTT_malloc + #include <stdlib.h> + #define STBTT_malloc(x,u) ((void)(u),malloc(x)) + #define STBTT_free(x,u) ((void)(u),free(x)) + #endif + + #ifndef STBTT_assert + #include <assert.h> + #define STBTT_assert(x) assert(x) + #endif + + #ifndef STBTT_strlen + #include <string.h> + #define STBTT_strlen(x) strlen(x) + #endif + + #ifndef STBTT_memcpy + #include <memory.h> + #define STBTT_memcpy memcpy + #define STBTT_memset memset + #endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// INTERFACE +//// +//// + +#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ +#define __STB_INCLUDE_STB_TRUETYPE_H__ + +#ifdef STBTT_STATIC +#define STBTT_DEF static +#else +#define STBTT_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// TEXTURE BAKING API +// +// If you use this API, you only have to call two functions ever. +// + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; +} stbtt_bakedchar; + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata, // you allocate this, it's num_chars long + void *user_allocator_context); // context for overriden STBTT_malloc +// if return is positive, the first unused row of the bitmap +// if return is negative, returns the negative of the number of characters that fit +// if return is 0, no characters fit and no rows were used +// This uses a very crappy packing. + +typedef struct +{ + float x0,y0,s0,t0; // top-left + float x1,y1,s1,t1; // bottom-right +} stbtt_aligned_quad; + +STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier +// Call GetBakedQuad with char_index = 'character - first_char', and it +// creates the quad you need to draw and advances the current position. +// +// The coordinate system used assumes y increases downwards. +// +// Characters will extend both above and below the current position; +// see discussion of "BASELINE" above. +// +// It's inefficient; you might want to c&p it and optimize it. + +STBTT_DEF void stbtt_GetBakedQuadUnrounded(stbtt_bakedchar *chardata, int pw, int ph, + int char_index, float *xpos, float *ypos, + stbtt_aligned_quad *q, int opengl_fillrule); +// Works just as stbtt_GetBakedQuad but does not round the x,y coordinates q to the pixels + +////////////////////////////////////////////////////////////////////////////// +// +// NEW TEXTURE BAKING API +// +// This provides options for packing multiple fonts into one atlas, not +// perfectly but better than nothing. + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; + float xoff2,yoff2; +} stbtt_packedchar; + +typedef struct stbtt_pack_context stbtt_pack_context; + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); +// Initializes a packing context stored in the passed-in stbtt_pack_context. +// Future calls using this context will pack characters into the bitmap passed +// in here: a 1-channel bitmap that is weight x height. stride_in_bytes is +// the distance from one row to the next (or 0 to mean they are packed tightly +// together). "padding" is // the amount of padding to leave between each +// character (normally you want '1' for bitmaps you'll use as textures with +// bilinear filtering). +// +// Returns 0 on failure, 1 on success. + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); +// Cleans up the packing context and frees all memory. + +#define STBTT_POINT_SIZE(x) (-(x)) + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, + int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); +// Creates character bitmaps from the font_index'th font found in fontdata (use +// font_index=0 if you don't know what that is). It creates num_chars_in_range +// bitmaps for characters with unicode values starting at first_unicode_char_in_range +// and increasing. Data for how to render them is stored in chardata_for_range; +// pass these to stbtt_GetPackedQuad to get back renderable quads. +// +// font_size is the full height of the character from ascender to descender, +// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed +// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() +// and pass that result as 'font_size': +// ..., 20 , ... // font max minus min y is 20 pixels tall +// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall + +typedef struct +{ + float font_size; + int first_unicode_char_in_range; + int num_chars_in_range; + stbtt_packedchar *chardata_for_range; // output +} stbtt_pack_range; + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +// Creates character bitmaps from multiple ranges of characters stored in +// ranges. This will usually create a better-packed bitmap than multiple +// calls to stbtt_PackFontRange. + + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); +// Oversampling a font increases the quality by allowing higher-quality subpixel +// positioning, and is especially valuable at smaller text sizes. +// +// This function sets the amount of oversampling for all following calls to +// stbtt_PackFontRange(s). The default (no oversampling) is achieved by +// h_oversample=1, v_oversample=1. The total number of pixels required is +// h_oversample*v_oversample larger than the default; for example, 2x2 +// oversampling requires 4x the storage of 1x1. For best results, render +// oversampled textures with bilinear filtering. Look at the readme in +// stb/tests/oversample for information about oversampled fonts + +STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int align_to_integer); + +// this is an opaque structure that you shouldn't mess with which holds +// all the context needed from PackBegin to PackEnd. +struct stbtt_pack_context { + void *user_allocator_context; + void *pack_info; + int width; + int height; + int stride_in_bytes; + int padding; + unsigned int h_oversample, v_oversample; + unsigned char *pixels; + void *nodes; +}; + +////////////////////////////////////////////////////////////////////////////// +// +// FONT LOADING +// +// + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); +// Each .ttf/.ttc file may have more than one font. Each font has a sequential +// index number starting from 0. Call this function to get the font offset for +// a given index; it returns -1 if the index is out of range. A regular .ttf +// file will only define one font and it always be at offset 0, so it will +// return '0' for index 0, and -1 for all other indices. You can just skip +// this step if you know it's that kind of font. + + +// The following structure is defined publically so you can declare one on +// the stack or as a global or etc, but you should treat it as opaque. +typedef struct stbtt_fontinfo +{ + void * userdata; + unsigned char * data; // pointer to .ttf file + int fontstart; // offset of start of font + + int numGlyphs; // number of glyphs, needed for range checking + + int loca,head,glyf,hhea,hmtx,kern; // table locations as offset from start of .ttf + int index_map; // a cmap mapping for our chosen character encoding + int indexToLocFormat; // format needed to map from glyph index to glyph +} stbtt_fontinfo; + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); +// Given an offset into the file that defines a font, this function builds +// the necessary cached info for the rest of the system. You must allocate +// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't +// need to do anything special to free it, because the contents are pure +// value data with no additional data structures. Returns 0 on failure. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER TO GLYPH-INDEX CONVERSIOn + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); +// If you're going to perform multiple operations on the same character +// and you want a speed-up, call this function with the character you're +// going to process, then use glyph-based functions instead of the +// codepoint-based functions. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER PROPERTIES +// + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose "height" is 'pixels' tall. +// Height is measured as the distance from the highest ascender to the lowest +// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics +// and computing: +// scale = pixels / (ascent - descent) +// so if you prefer to measure height by the ascent only, use a similar calculation. + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose EM size is mapped to +// 'pixels' tall. This is probably what traditional APIs compute, but +// I'm not positive. + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); +// ascent is the coordinate above the baseline the font extends; descent +// is the coordinate below the baseline the font extends (i.e. it is typically negative) +// lineGap is the spacing between one row's descent and the next row's ascent... +// so you should advance the vertical position by "*ascent - *descent + *lineGap" +// these are expressed in unscaled coordinates, so you must multiply by +// the scale factor for a given size + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); +// the bounding box around all possible characters + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); +// leftSideBearing is the offset from the current horizontal position to the left edge of the character +// advanceWidth is the offset from the current horizontal position to the next horizontal position +// these are expressed in unscaled coordinates + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); +// an additional amount to add to the 'advance' value between ch1 and ch2 + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); +// Gets the bounding box of the visible part of the glyph, in unscaled coordinates + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); +// as above, but takes one or more glyph indices for greater efficiency + + +////////////////////////////////////////////////////////////////////////////// +// +// GLYPH SHAPES (you probably don't need these, but they have to go before +// the bitmaps for C declaration-order reasons) +// + +#ifndef STBTT_vmove // you can predefine these to use different values (but why?) + enum { + STBTT_vmove=1, + STBTT_vline, + STBTT_vcurve + }; +#endif + +#ifndef stbtt_vertex // you can predefine this to use different values + // (we share this with other code at RAD) + #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file + typedef struct + { + stbtt_vertex_type x,y,cx,cy; + unsigned char type,padding; + } stbtt_vertex; +#endif + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); +// returns non-zero if nothing is drawn for this glyph + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); +// returns # of vertices and fills *vertices with the pointer to them +// these are expressed in "unscaled" coordinates +// +// The shape is a series of countours. Each one starts with +// a STBTT_moveto, then consists of a series of mixed +// STBTT_lineto and STBTT_curveto segments. A lineto +// draws a line from previous endpoint to its x,y; a curveto +// draws a quadratic bezier from previous endpoint to +// its x,y, using cx,cy as the bezier control point. + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); +// frees the data allocated above + +////////////////////////////////////////////////////////////////////////////// +// +// BITMAP RENDERING +// + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); +// frees the bitmap allocated below + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// allocates a large-enough single-channel 8bpp bitmap and renders the +// specified character/glyph at the specified scale into it, with +// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). +// *width & *height are filled out with the width & height of the bitmap, +// which is stored left-to-right, top-to-bottom. +// +// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); +// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap +// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap +// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the +// width and height and positioning info for it first. + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); +// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +// get the bbox of the bitmap centered around the glyph origin; so the +// bitmap width is ix1-ix0, height is iy1-iy0, and location to place +// the bitmap top left is (leftSideBearing*scale,iy0). +// (Note that the bitmap uses y-increases-down, but the shape uses +// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); +// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel +// shift for the character + +// the following functions are equivalent to the above functions, but operate +// on glyph indices instead of Unicode codepoints (for efficiency) +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); + + +// @TODO: don't expose this structure +typedef struct +{ + int w,h,stride; + unsigned char *pixels; +} stbtt__bitmap; + +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata); + +////////////////////////////////////////////////////////////////////////////// +// +// Finding the right font... +// +// You should really just solve this offline, keep your own tables +// of what font is what, and don't try to get it out of the .ttf file. +// That's because getting it out of the .ttf file is really hard, because +// the names in the file can appear in many possible encodings, in many +// possible languages, and e.g. if you need a case-insensitive comparison, +// the details of that depend on the encoding & language in a complex way +// (actually underspecified in truetype, but also gigantic). +// +// But you can use the provided functions in two possible ways: +// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on +// unicode-encoded names to try to find the font you want; +// you can run this before calling stbtt_InitFont() +// +// stbtt_GetFontNameString() lets you get any of the various strings +// from the file yourself and do your own comparisons on them. +// You have to have called stbtt_InitFont() first. + + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); +// returns the offset (not index) of the font that matches, or -1 if none +// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". +// if you use any other flag, use a font name like "Arial"; this checks +// the 'macStyle' header field; i don't know if fonts set this consistently +#define STBTT_MACSTYLE_DONTCARE 0 +#define STBTT_MACSTYLE_BOLD 1 +#define STBTT_MACSTYLE_ITALIC 2 +#define STBTT_MACSTYLE_UNDERSCORE 4 +#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); +// returns 1/0 whether the first string interpreted as utf8 is identical to +// the second string interpreted as big-endian utf16... useful for strings from next func + +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); +// returns the string (which may be big-endian double byte, e.g. for unicode) +// and puts the length in bytes in *length. +// +// some of the values for the IDs are below; for more see the truetype spec: +// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html +// http://www.microsoft.com/typography/otspec/name.htm + +enum { // platformID + STBTT_PLATFORM_ID_UNICODE =0, + STBTT_PLATFORM_ID_MAC =1, + STBTT_PLATFORM_ID_ISO =2, + STBTT_PLATFORM_ID_MICROSOFT =3 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_UNICODE + STBTT_UNICODE_EID_UNICODE_1_0 =0, + STBTT_UNICODE_EID_UNICODE_1_1 =1, + STBTT_UNICODE_EID_ISO_10646 =2, + STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, + STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT + STBTT_MS_EID_SYMBOL =0, + STBTT_MS_EID_UNICODE_BMP =1, + STBTT_MS_EID_SHIFTJIS =2, + STBTT_MS_EID_UNICODE_FULL =10 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes + STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, + STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, + STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, + STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 +}; + +enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, + STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, + STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, + STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, + STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, + STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D +}; + +enum { // languageID for STBTT_PLATFORM_ID_MAC + STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, + STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, + STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, + STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , + STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , + STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, + STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 +}; + +#ifdef __cplusplus +} +#endif + +#endif // __STB_INCLUDE_STB_TRUETYPE_H__ + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// IMPLEMENTATION +//// +//// + +#ifdef STB_TRUETYPE_IMPLEMENTATION + +#ifndef STBTT_MAX_OVERSAMPLE +#define STBTT_MAX_OVERSAMPLE 8 +#endif + +typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; + +////////////////////////////////////////////////////////////////////////// +// +// accessors to parse data from file +// + +// on platforms that don't allow misaligned reads, if we want to allow +// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE + +#define ttBYTE(p) (* (stbtt_uint8 *) (p)) +#define ttCHAR(p) (* (stbtt_int8 *) (p)) +#define ttFixed(p) ttLONG(p) + +#if defined(STB_TRUETYPE_BIGENDIAN) && !defined(ALLOW_UNALIGNED_TRUETYPE) + + #define ttUSHORT(p) (* (stbtt_uint16 *) (p)) + #define ttSHORT(p) (* (stbtt_int16 *) (p)) + #define ttULONG(p) (* (stbtt_uint32 *) (p)) + #define ttLONG(p) (* (stbtt_int32 *) (p)) + +#else + + static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } + static stbtt_int16 ttSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } + static stbtt_uint32 ttULONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } + static stbtt_int32 ttLONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } + +#endif + +#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) +#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) + +static int stbtt__isfont(const stbtt_uint8 *font) +{ + // check the version number + if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 + if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! + if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF + if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + return 0; +} + +// @OPTIMIZE: binary search +static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) +{ + stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); + stbtt_uint32 tabledir = fontstart + 12; + stbtt_int32 i; + for (i=0; i < num_tables; ++i) { + stbtt_uint32 loc = tabledir + 16*i; + if (stbtt_tag(data+loc+0, tag)) + return ttULONG(data+loc+8); + } + return 0; +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index) +{ + // if it's just a font, there's only one valid index + if (stbtt__isfont(font_collection)) + return index == 0 ? 0 : -1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + stbtt_int32 n = ttLONG(font_collection+8); + if (index >= n) + return -1; + return ttULONG(font_collection+12+index*14); + } + } + return -1; +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart) +{ + stbtt_uint8 *data = (stbtt_uint8 *) data2; + stbtt_uint32 cmap, t; + stbtt_int32 i,numTables; + + info->data = data; + info->fontstart = fontstart; + + cmap = stbtt__find_table(data, fontstart, "cmap"); // required + info->loca = stbtt__find_table(data, fontstart, "loca"); // required + info->head = stbtt__find_table(data, fontstart, "head"); // required + info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required + info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required + info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required + info->kern = stbtt__find_table(data, fontstart, "kern"); // not required + if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx) + return 0; + + t = stbtt__find_table(data, fontstart, "maxp"); + if (t) + info->numGlyphs = ttUSHORT(data+t+4); + else + info->numGlyphs = 0xffff; + + // find a cmap encoding table we understand *now* to avoid searching + // later. (todo: could make this installable) + // the same regardless of glyph. + numTables = ttUSHORT(data + cmap + 2); + info->index_map = 0; + for (i=0; i < numTables; ++i) { + stbtt_uint32 encoding_record = cmap + 4 + 8 * i; + // find an encoding we understand: + switch(ttUSHORT(data+encoding_record)) { + case STBTT_PLATFORM_ID_MICROSOFT: + switch (ttUSHORT(data+encoding_record+2)) { + case STBTT_MS_EID_UNICODE_BMP: + case STBTT_MS_EID_UNICODE_FULL: + // MS/Unicode + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + break; + case STBTT_PLATFORM_ID_UNICODE: + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + } + if (info->index_map == 0) + return 0; + + info->indexToLocFormat = ttUSHORT(data+info->head + 50); + return 1; +} + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) +{ + stbtt_uint8 *data = info->data; + stbtt_uint32 index_map = info->index_map; + + stbtt_uint16 format = ttUSHORT(data + index_map + 0); + if (format == 0) { // apple byte encoding + stbtt_int32 bytes = ttUSHORT(data + index_map + 2); + if (unicode_codepoint < bytes-6) + return ttBYTE(data + index_map + 6 + unicode_codepoint); + return 0; + } else if (format == 6) { + stbtt_uint32 first = ttUSHORT(data + index_map + 6); + stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); + return 0; + } else if (format == 2) { + STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean + return 0; + } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges + stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); + stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + + // do a binary search of the segments + stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; + + if (unicode_codepoint > 0xffff) + return 0; + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) + search += rangeShift*2; + + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange*2); + if (unicode_codepoint > end) + search += searchRange*2; + --entrySelector; + } + search += 2; + + { + stbtt_uint16 offset, start; + stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + + STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); + start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); + if (unicode_codepoint < start) + return 0; + + offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); + if (offset == 0) + return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + + return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); + } + } else if (format == 12 || format == 13) { + stbtt_uint32 ngroups = ttULONG(data+index_map+12); + stbtt_int32 low,high; + low = 0; high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) { + stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high + stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); + stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); + if ((stbtt_uint32) unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32) unicode_codepoint > end_char) + low = mid+1; + else { + stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); + if (format == 12) + return start_glyph + unicode_codepoint-start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found + } + // @TODO + STBTT_assert(0); + return 0; +} + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) +{ + return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); +} + +static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) +{ + v->type = type; + v->x = (stbtt_int16) x; + v->y = (stbtt_int16) y; + v->cx = (stbtt_int16) cx; + v->cy = (stbtt_int16) cy; +} + +static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) +{ + int g1,g2; + + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range + if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format + + if (info->indexToLocFormat == 0) { + g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; + g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; + } else { + g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); + g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); + } + + return g1==g2 ? -1 : g1; // if length is 0, return -1 +} + +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; + + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + return 1; +} + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) +{ + return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); +} + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt_int16 numberOfContours; + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 1; + numberOfContours = ttSHORT(info->data + g); + return numberOfContours == 0; +} + +static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, + stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) +{ + if (start_off) { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); + } + return num_vertices; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + stbtt_int16 numberOfContours; + stbtt_uint8 *endPtsOfContours; + stbtt_uint8 *data = info->data; + stbtt_vertex *vertices=0; + int num_vertices=0; + int g = stbtt__GetGlyfOffset(info, glyph_index); + + *pvertices = NULL; + + if (g < 0) return 0; + + numberOfContours = ttSHORT(data + g); + + if (numberOfContours > 0) { + stbtt_uint8 flags=0,flagcount; + stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; + stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; + stbtt_uint8 *points; + endPtsOfContours = (data + g + 10); + ins = ttUSHORT(data + g + 10 + numberOfContours * 2); + points = data + g + 10 + numberOfContours * 2 + 2 + ins; + + n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); + + m = n + 2*numberOfContours; // a loose bound on how many vertices we might need + vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); + if (vertices == 0) + return 0; + + next_move = 0; + flagcount=0; + + // in first pass, we load uninterpreted data into the allocated array + // above, shifted to the end of the array so we won't overwrite it when + // we create our final data starting from the front + + off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated + + // first load flags + + for (i=0; i < n; ++i) { + if (flagcount == 0) { + flags = *points++; + if (flags & 8) + flagcount = *points++; + } else + --flagcount; + vertices[off+i].type = flags; + } + + // now load x coordinates + x=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 2) { + stbtt_int16 dx = *points++; + x += (flags & 16) ? dx : -dx; // ??? + } else { + if (!(flags & 16)) { + x = x + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].x = (stbtt_int16) x; + } + + // now load y coordinates + y=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 4) { + stbtt_int16 dy = *points++; + y += (flags & 32) ? dy : -dy; // ??? + } else { + if (!(flags & 32)) { + y = y + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].y = (stbtt_int16) y; + } + + // now convert them to our format + num_vertices=0; + sx = sy = cx = cy = scx = scy = 0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + x = (stbtt_int16) vertices[off+i].x; + y = (stbtt_int16) vertices[off+i].y; + + if (next_move == i) { + if (i != 0) + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + + // now start the new one + start_off = !(flags & 1); + if (start_off) { + // if we start off with an off-curve point, then when we need to find a point on the curve + // where we can start, and we need to save some state for when we wraparound. + scx = x; + scy = y; + if (!(vertices[off+i+1].type & 1)) { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; + sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = (stbtt_int32) vertices[off+i+1].x; + sy = (stbtt_int32) vertices[off+i+1].y; + ++i; // we're using point i+1 as the starting point, so skip it + } + } else { + sx = x; + sy = y; + } + stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); + was_off = 0; + next_move = 1 + ttUSHORT(endPtsOfContours+j*2); + ++j; + } else { + if (!(flags & 1)) { // if it's a curve + if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); + cx = x; + cy = y; + was_off = 1; + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); + was_off = 0; + } + } + } + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + } else if (numberOfContours == -1) { + // Compound shapes. + int more = 1; + stbtt_uint8 *comp = data + g + 10; + num_vertices = 0; + vertices = 0; + while (more) { + stbtt_uint16 flags, gidx; + int comp_num_verts = 0, i; + stbtt_vertex *comp_verts = 0, *tmp = 0; + float mtx[6] = {1,0,0,1,0,0}, m, n; + + flags = ttSHORT(comp); comp+=2; + gidx = ttSHORT(comp); comp+=2; + + if (flags & 2) { // XY values + if (flags & 1) { // shorts + mtx[4] = ttSHORT(comp); comp+=2; + mtx[5] = ttSHORT(comp); comp+=2; + } else { + mtx[4] = ttCHAR(comp); comp+=1; + mtx[5] = ttCHAR(comp); comp+=1; + } + } + else { + // @TODO handle matching point + STBTT_assert(0); + } + if (flags & (1<<3)) { // WE_HAVE_A_SCALE + mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } + + // Find transformation scales. + m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); + n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); + + // Get indexed glyph. + comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); + if (comp_num_verts > 0) { + // Transform vertices. + for (i = 0; i < comp_num_verts; ++i) { + stbtt_vertex* v = &comp_verts[i]; + stbtt_vertex_type x,y; + x=v->x; y=v->y; + v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + x=v->cx; y=v->cy; + v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + } + // Append vertices. + tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); + if (!tmp) { + if (vertices) STBTT_free(vertices, info->userdata); + if (comp_verts) STBTT_free(comp_verts, info->userdata); + return 0; + } + if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); + STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); + if (vertices) STBTT_free(vertices, info->userdata); + vertices = tmp; + STBTT_free(comp_verts, info->userdata); + num_vertices += comp_num_verts; + } + // More components ? + more = flags & (1<<5); + } + } else if (numberOfContours < 0) { + // @TODO other compound variations? + STBTT_assert(0); + } else { + // numberOfCounters == 0, do nothing + } + + *pvertices = vertices; + return num_vertices; +} + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) +{ + stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); + if (glyph_index < numOfLongHorMetrics) { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); + } else { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); + } +} + +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint8 *data = info->data + info->kern; + stbtt_uint32 needle, straw; + int l, r, m; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + l = 0; + r = ttUSHORT(data+10) - 1; + needle = glyph1 << 16 | glyph2; + while (l <= r) { + m = (l + r) >> 1; + straw = ttULONG(data+18+(m*6)); // note: unaligned read + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else + return ttSHORT(data+22+(m*6)); + } + return 0; +} + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) +{ + if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs + return 0; + return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); +} + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) +{ + stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); +} + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) +{ + if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); + if (descent) *descent = ttSHORT(info->data+info->hhea + 6); + if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); +} + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) +{ + *x0 = ttSHORT(info->data + info->head + 36); + *y0 = ttSHORT(info->data + info->head + 38); + *x1 = ttSHORT(info->data + info->head + 40); + *y1 = ttSHORT(info->data + info->head + 42); +} + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) +{ + int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); + return (float) height / fheight; +} + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) +{ + int unitsPerEm = ttUSHORT(info->data + info->head + 18); + return pixels / unitsPerEm; +} + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) +{ + STBTT_free(v, info->userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// antialiasing software rasterizer +// + +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + int x0,y0,x1,y1; + if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { + // e.g. space character + if (ix0) *ix0 = 0; + if (iy0) *iy0 = 0; + if (ix1) *ix1 = 0; + if (iy1) *iy1 = 0; + } else { + // move to integral bboxes (treating pixels as little squares, what pixels get touched)? + if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); + if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); + if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); + if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); + } +} + +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); +} + +typedef struct stbtt__edge { + float x0,y0, x1,y1; + int invert; +} stbtt__edge; + +typedef struct stbtt__active_edge +{ + int x,dx; + float ey; + struct stbtt__active_edge *next; + int valid; +} stbtt__active_edge; + +#define FIXSHIFT 10 +#define FIX (1 << FIXSHIFT) +#define FIXMASK (FIX-1) + +static stbtt__active_edge *new_active(stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) STBTT_malloc(sizeof(*z), userdata); // @TODO: make a pool of these!!! + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(e->y0 <= start_point); + if (!z) return z; + // round dx down to avoid going too far + if (dxdy < 0) + z->dx = -STBTT_ifloor(FIX * -dxdy); + else + z->dx = STBTT_ifloor(FIX * dxdy); + z->x = STBTT_ifloor(FIX * (e->x0 + dxdy * (start_point - e->y0))); + z->x -= off_x * FIX; + z->ey = e->y1; + z->next = 0; + z->valid = e->invert ? 1 : -1; + return z; +} + +// note: this routine clips fills that extend off the edges... ideally this +// wouldn't happen, but it could happen if the truetype glyph bounding boxes +// are wrong, or if the user supplies a too-small bitmap +static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) +{ + // non-zero winding fill + int x0=0, w=0; + + while (e) { + if (w == 0) { + // if we're currently at zero, we need to record the edge start point + x0 = e->x; w += e->valid; + } else { + int x1 = e->x; w += e->valid; + // if we went to zero, we need to draw + if (w == 0) { + int i = x0 >> FIXSHIFT; + int j = x1 >> FIXSHIFT; + + if (i < len && j >= 0) { + if (i == j) { + // x0,x1 are the same pixel, so compute combined coverage + scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> FIXSHIFT); + } else { + if (i >= 0) // add antialiasing for x0 + scanline[i] = scanline[i] + (stbtt_uint8) (((FIX - (x0 & FIXMASK)) * max_weight) >> FIXSHIFT); + else + i = -1; // clip + + if (j < len) // add antialiasing for x1 + scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & FIXMASK) * max_weight) >> FIXSHIFT); + else + j = len; // clip + + for (++i; i < j; ++i) // fill pixels between x0 and x1 + scanline[i] = scanline[i] + (stbtt_uint8) max_weight; + } + } + } + } + + e = e->next; + } +} + +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__active_edge *active = NULL; + int y,j=0; + int max_weight = (255 / vsubsample); // weight per vertical scanline + int s; // vertical subsample index + unsigned char scanline_data[512], *scanline; + + if (result->w > 512) + scanline = (unsigned char *) STBTT_malloc(result->w, userdata); + else + scanline = scanline_data; + + y = off_y * vsubsample; + e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; + + while (j < result->h) { + STBTT_memset(scanline, 0, result->w); + for (s=0; s < vsubsample; ++s) { + // find center of pixel for this scanline + float scan_y = y + 0.5f; + stbtt__active_edge **step = &active; + + // update all active edges; + // remove all active edges that terminate before the center of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y) { + *step = z->next; // delete from list + STBTT_assert(z->valid); + z->valid = 0; + STBTT_free(z, userdata); + } else { + z->x += z->dx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + } + + // resort the list if needed + for(;;) { + int changed=0; + step = &active; + while (*step && (*step)->next) { + if ((*step)->x > (*step)->next->x) { + stbtt__active_edge *t = *step; + stbtt__active_edge *q = t->next; + + t->next = q->next; + q->next = t; + *step = q; + changed = 1; + } + step = &(*step)->next; + } + if (!changed) break; + } + + // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + while (e->y0 <= scan_y) { + if (e->y1 > scan_y) { + stbtt__active_edge *z = new_active(e, off_x, scan_y, userdata); + // find insertion point + if (active == NULL) + active = z; + else if (z->x < active->x) { + // insert at front + z->next = active; + active = z; + } else { + // find thing to insert AFTER + stbtt__active_edge *p = active; + while (p->next && p->next->x < z->x) + p = p->next; + // at this point, p->next->x is NOT < z->x + z->next = p->next; + p->next = z; + } + } + ++e; + } + + // now process all active edges in XOR fashion + if (active) + stbtt__fill_active_edges(scanline, result->w, active, max_weight); + + ++y; + } + STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); + ++j; + } + + while (active) { + stbtt__active_edge *z = active; + active = active->next; + STBTT_free(z, userdata); + } + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} + +static int stbtt__edge_compare(const void *p, const void *q) +{ + stbtt__edge *a = (stbtt__edge *) p; + stbtt__edge *b = (stbtt__edge *) q; + + if (a->y0 < b->y0) return -1; + if (a->y0 > b->y0) return 1; + return 0; +} + +typedef struct +{ + float x,y; +} stbtt__point; + +static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) +{ + float y_scale_inv = invert ? -scale_y : scale_y; + stbtt__edge *e; + int n,i,j,k,m; + int vsubsample = result->h < 8 ? 15 : 5; + // vsubsample should divide 255 evenly; otherwise we won't reach full opacity + + // now we have to blow out the windings into explicit edge lists + n = 0; + for (i=0; i < windings; ++i) + n += wcount[i]; + + e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel + if (e == 0) return; + n = 0; + + m=0; + for (i=0; i < windings; ++i) { + stbtt__point *p = pts + m; + m += wcount[i]; + j = wcount[i]-1; + for (k=0; k < wcount[i]; j=k++) { + int a=k,b=j; + // skip the edge if horizontal + if (p[j].y == p[k].y) + continue; + // add edge from j to k to the list + e[n].invert = 0; + if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { + e[n].invert = 1; + a=j,b=k; + } + e[n].x0 = p[a].x * scale_x + shift_x; + e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; + e[n].x1 = p[b].x * scale_x + shift_x; + e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; + ++n; + } + } + + // now sort the edges by their highest point (should snap to integer, and then by x) + STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); + + // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule + stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); + + STBTT_free(e, userdata); +} + +static void stbtt__add_point(stbtt__point *points, int n, float x, float y) +{ + if (!points) return; // during first pass, it's unallocated + points[n].x = x; + points[n].y = y; +} + +// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching +static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) +{ + // midpoint + float mx = (x0 + 2*x1 + x2)/4; + float my = (y0 + 2*y1 + y2)/4; + // versus directly drawn line + float dx = (x0+x2)/2 - mx; + float dy = (y0+y2)/2 - my; + if (n > 16) // 65536 segments on one curve better be enough! + return 1; + if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA + stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x2,y2); + *num_points = *num_points+1; + } + return 1; +} + +// returns number of contours +static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) +{ + stbtt__point *points=0; + int num_points=0; + + float objspace_flatness_squared = objspace_flatness * objspace_flatness; + int i,n=0,start=0, pass; + + // count how many "moves" there are to get the contour count + for (i=0; i < num_verts; ++i) + if (vertices[i].type == STBTT_vmove) + ++n; + + *num_contours = n; + if (n == 0) return 0; + + *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); + + if (*contour_lengths == 0) { + *num_contours = 0; + return 0; + } + + // make two passes through the points so we don't need to realloc + for (pass=0; pass < 2; ++pass) { + float x=0,y=0; + if (pass == 1) { + points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); + if (points == NULL) goto error; + } + num_points = 0; + n= -1; + for (i=0; i < num_verts; ++i) { + switch (vertices[i].type) { + case STBTT_vmove: + // start the next contour + if (n >= 0) + (*contour_lengths)[n] = num_points - start; + ++n; + start = num_points; + + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x,y); + break; + case STBTT_vline: + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x, y); + break; + case STBTT_vcurve: + stbtt__tesselate_curve(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + } + } + (*contour_lengths)[n] = num_points - start; + } + + return points; +error: + STBTT_free(points, userdata); + STBTT_free(*contour_lengths, userdata); + *contour_lengths = 0; + *num_contours = 0; + return NULL; +} + +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) +{ + float scale = scale_x > scale_y ? scale_y : scale_x; + int winding_count, *winding_lengths; + stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); + if (windings) { + stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); + STBTT_free(winding_lengths, userdata); + STBTT_free(windings, userdata); + } +} + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + int ix0,iy0,ix1,iy1; + stbtt__bitmap gbm; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) return NULL; + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); + + // now we get the size + gbm.w = (ix1 - ix0); + gbm.h = (iy1 - iy0); + gbm.pixels = NULL; // in case we error + + if (width ) *width = gbm.w; + if (height) *height = gbm.h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + if (gbm.w && gbm.h) { + gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); + if (gbm.pixels) { + gbm.stride = gbm.w; + + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); + } + } + STBTT_free(vertices, info->userdata); + return gbm.pixels; +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) +{ + int ix0,iy0; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + stbtt__bitmap gbm; + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); + gbm.pixels = output; + gbm.w = out_w; + gbm.h = out_h; + gbm.stride = out_stride; + + if (gbm.w && gbm.h) + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); + + STBTT_free(vertices, info->userdata); +} + +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) +{ + stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); +} + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-CRAPPY packing to keep source code small + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata, void *user_allocator_callback) +{ + float scale; + int x,y,bottom_y, i; + stbtt_fontinfo info; + info.userdata = user_allocator_callback; + if (!stbtt_InitFont(&info, data, offset)) + return -1; + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + x=y=1; + bottom_y = 1; + + scale = stbtt_ScaleForPixelHeight(&info, pixel_height); + + for (i=0; i < num_chars; ++i) { + int advance, lsb, x0,y0,x1,y1,gw,gh; + int g = stbtt_FindGlyphIndex(&info, first_char + i); + stbtt_GetGlyphHMetrics(&info, g, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&info, g, scale,scale, &x0,&y0,&x1,&y1); + gw = x1-x0; + gh = y1-y0; + if (x + gw + 1 >= pw) + y = bottom_y, x = 1; // advance to next row + if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row + return -i; + STBTT_assert(x+gw < pw); + STBTT_assert(y+gh < ph); + stbtt_MakeGlyphBitmap(&info, pixels+x+y*pw, gw,gh,pw, scale,scale, g); + chardata[i].x0 = (stbtt_int16) x; + chardata[i].y0 = (stbtt_int16) y; + chardata[i].x1 = (stbtt_int16) (x + gw); + chardata[i].y1 = (stbtt_int16) (y + gh); + chardata[i].xadvance = scale * advance; + chardata[i].xoff = (float) x0; + chardata[i].yoff = (float) y0; + x = x + gw + 1; + if (y+gh+1 > bottom_y) + bottom_y = y+gh+1; + } + return bottom_y; +} + +STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +{ + float d3d_bias = opengl_fillrule ? 0 : -0.5f; + float ipw = 1.0f / pw, iph = 1.0f / ph; + stbtt_bakedchar *b = chardata + char_index; + int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); + int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); + + q->x0 = round_x + d3d_bias; + q->y0 = round_y + d3d_bias; + q->x1 = round_x + b->x1 - b->x0 + d3d_bias; + q->y1 = round_y + b->y1 - b->y0 + d3d_bias; + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + //*xpos += b->xadvance; +} + +STBTT_DEF void stbtt_GetBakedQuadUnrounded(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +{ + float d3d_bias = opengl_fillrule ? 0 : -0.5f; + float ipw = 1.0f / pw, iph = 1.0f / ph; + stbtt_bakedchar *b = chardata + char_index; + + float x = *xpos + b->xoff; + float y = *ypos + b->yoff; + + q->x0 = x + d3d_bias; + q->y0 = y + d3d_bias; + q->x1 = x + b->x1 - b->x0 + d3d_bias; + q->y1 = y + b->y1 - b->y0 + d3d_bias; + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + //*xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// rectangle packing replacement routines if you don't have stb_rect_pack.h +// + +#ifndef STB_RECT_PACK_VERSION +#ifdef _MSC_VER +#define STBTT__NOTUSED(v) (void)(v) +#else +#define STBTT__NOTUSED(v) (void)sizeof(v) +#endif + +typedef int stbrp_coord; + +//////////////////////////////////////////////////////////////////////////////////// +// // +// // +// COMPILER WARNING ?!?!? // +// // +// // +// if you get a compile warning due to these symbols being defined more than // +// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // +// // +//////////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + int width,height; + int x,y,bottom_y; +} stbrp_context; + +typedef struct +{ + unsigned char x; +} stbrp_node; + +typedef struct +{ + stbrp_coord x,y; + int id,w,h,was_packed; +} stbrp_rect; + +static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) +{ + con->width = pw; + con->height = ph; + con->x = 0; + con->y = 0; + con->bottom_y = 0; + STBTT__NOTUSED(nodes); + STBTT__NOTUSED(num_nodes); +} + +static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) +{ + int i; + for (i=0; i < num_rects; ++i) { + if (con->x + rects[i].w > con->width) { + con->x = 0; + con->y = con->bottom_y; + } + if (con->y + rects[i].h > con->height) + break; + rects[i].x = con->x; + rects[i].y = con->y; + rects[i].was_packed = 1; + con->x += rects[i].w; + if (con->y + rects[i].h > con->bottom_y) + con->bottom_y = con->y + rects[i].h; + } + for ( ; i < num_rects; ++i) + rects[i].was_packed = 0; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If +// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) +{ + stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); + int num_nodes = pw - padding; + stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); + + if (context == NULL || nodes == NULL) { + if (context != NULL) STBTT_free(context, alloc_context); + if (nodes != NULL) STBTT_free(nodes , alloc_context); + return 0; + } + + spc->user_allocator_context = alloc_context; + spc->width = pw; + spc->height = ph; + spc->pixels = pixels; + spc->pack_info = context; + spc->nodes = nodes; + spc->padding = padding; + spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; + spc->h_oversample = 1; + spc->v_oversample = 1; + + stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); + + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + + return 1; +} + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) +{ + STBTT_free(spc->nodes , spc->user_allocator_context); + STBTT_free(spc->pack_info, spc->user_allocator_context); +} + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) +{ + STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); + STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); + if (h_oversample <= STBTT_MAX_OVERSAMPLE) + spc->h_oversample = h_oversample; + if (v_oversample <= STBTT_MAX_OVERSAMPLE) + spc->v_oversample = v_oversample; +} + +#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) + +static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_w = w - kernel_width; + int j; + for (j=0; j < h; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 4); + } + break; + default: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < w; ++i) { + STBTT_assert(pixels[i] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i] = (unsigned char) (total / kernel_width); + } + + pixels += stride_in_bytes; + } +} + +static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_h = h - kernel_width; + int j; + for (j=0; j < w; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 4); + } + break; + default: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < h; ++i) { + STBTT_assert(pixels[i*stride_in_bytes] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + + pixels += 1; + } +} + +static float stbtt__oversample_shift(int oversample) +{ + if (!oversample) + return 0.0f; + + // The prefilter is a box filter of width "oversample", + // which shifts phase by (oversample - 1)/2 pixels in + // oversampled space. We want to shift in the opposite + // direction to counter this. + return (float)-(oversample - 1) / (2.0f * (float)oversample); +} + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +{ + stbtt_fontinfo info; + float recip_h = 1.0f / spc->h_oversample; + float recip_v = 1.0f / spc->v_oversample; + float sub_x = stbtt__oversample_shift(spc->h_oversample); + float sub_y = stbtt__oversample_shift(spc->v_oversample); + int i,j,k,n, return_value = 1; + stbrp_context *context = (stbrp_context *) spc->pack_info; + stbrp_rect *rects; + + // flag all characters as NOT packed + for (i=0; i < num_ranges; ++i) + for (j=0; j < ranges[i].num_chars_in_range; ++j) + ranges[i].chardata_for_range[j].x0 = + ranges[i].chardata_for_range[j].y0 = + ranges[i].chardata_for_range[j].x1 = + ranges[i].chardata_for_range[j].y1 = 0; + + n = 0; + for (i=0; i < num_ranges; ++i) + n += ranges[i].num_chars_in_range; + + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); + if (rects == NULL) + return 0; + + info.userdata = spc->user_allocator_context; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); + k=0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForMappingEmToPixels(&info, -fh); + for (j=0; j < ranges[i].num_chars_in_range; ++j) { + int x0,y0,x1,y1; + stbtt_GetCodepointBitmapBoxSubpixel(&info, ranges[i].first_unicode_char_in_range + j, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + ++k; + } + } + + stbrp_pack_rects(context, rects, k); + + k = 0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForMappingEmToPixels(&info, -fh); + for (j=0; j < ranges[i].num_chars_in_range; ++j) { + stbrp_rect *r = &rects[k]; + if (r->was_packed) { + stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; + int advance, lsb, x0,y0,x1,y1; + int glyph = stbtt_FindGlyphIndex(&info, ranges[i].first_unicode_char_in_range + j); + stbrp_coord pad = (stbrp_coord) spc->padding; + + // pad on left and top + r->x += pad; + r->y += pad; + r->w -= pad; + r->h -= pad; + stbtt_GetGlyphHMetrics(&info, glyph, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&info, glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + &x0,&y0,&x1,&y1); + stbtt_MakeGlyphBitmapSubpixel(&info, + spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w - spc->h_oversample+1, + r->h - spc->v_oversample+1, + spc->stride_in_bytes, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + glyph); + + if (spc->h_oversample > 1) + stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->h_oversample); + + if (spc->v_oversample > 1) + stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->v_oversample); + + bc->x0 = (stbtt_int16) r->x; + bc->y0 = (stbtt_int16) r->y; + bc->x1 = (stbtt_int16) (r->x + r->w); + bc->y1 = (stbtt_int16) (r->y + r->h); + bc->xadvance = scale * advance; + bc->xoff = (float) x0 * recip_h + sub_x; + bc->yoff = (float) y0 * recip_v + sub_y; + bc->xoff2 = (x0 + r->w) * recip_h + sub_x; + bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + } else { + return_value = 0; // if any fail, report failure + } + + ++k; + } + } + + STBTT_free(rects, spc->user_allocator_context); + return return_value; +} + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, + int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) +{ + stbtt_pack_range range; + range.first_unicode_char_in_range = first_unicode_char_in_range; + range.num_chars_in_range = num_chars_in_range; + range.chardata_for_range = chardata_for_range; + range.font_size = font_size; + return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); +} + +STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +{ + float ipw = 1.0f / pw, iph = 1.0f / ph; + stbtt_packedchar *b = chardata + char_index; + + if (align_to_integer) { + float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); + float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); + q->x0 = x; + q->y0 = y; + q->x1 = x + b->xoff2 - b->xoff; + q->y1 = y + b->yoff2 - b->yoff; + } else { + q->x0 = *xpos + b->xoff; + q->y0 = *ypos + b->yoff; + q->x1 = *xpos + b->xoff2; + q->y1 = *ypos + b->yoff2; + } + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + + +////////////////////////////////////////////////////////////////////////////// +// +// font name matching -- recommended not to use this +// + +// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) +{ + stbtt_int32 i=0; + + // convert utf16 to utf8 and compare the results while converting + while (len2) { + stbtt_uint16 ch = s2[0]*256 + s2[1]; + if (ch < 0x80) { + if (i >= len1) return -1; + if (s1[i++] != ch) return -1; + } else if (ch < 0x800) { + if (i+1 >= len1) return -1; + if (s1[i++] != 0xc0 + (ch >> 6)) return -1; + if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; + } else if (ch >= 0xd800 && ch < 0xdc00) { + stbtt_uint32 c; + stbtt_uint16 ch2 = s2[2]*256 + s2[3]; + if (i+3 >= len1) return -1; + c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; + if (s1[i++] != 0xf0 + (c >> 18)) return -1; + if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; + s2 += 2; // plus another 2 below + len2 -= 2; + } else if (ch >= 0xdc00 && ch < 0xe000) { + return -1; + } else { + if (i+2 >= len1) return -1; + if (s1[i++] != 0xe0 + (ch >> 12)) return -1; + if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; + } + s2 += 2; + len2 -= 2; + } + return i; +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); +} + +// returns results in whatever encoding you request... but note that 2-byte encodings +// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) +{ + stbtt_int32 i,count,stringOffset; + stbtt_uint8 *fc = font->data; + stbtt_uint32 offset = font->fontstart; + stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return NULL; + + count = ttUSHORT(fc+nm+2); + stringOffset = nm + ttUSHORT(fc+nm+4); + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) + && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { + *length = ttUSHORT(fc+loc+8); + return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); + } + } + return NULL; +} + +static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) +{ + stbtt_int32 i; + stbtt_int32 count = ttUSHORT(fc+nm+2); + stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); + + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + stbtt_int32 id = ttUSHORT(fc+loc+6); + if (id == target_id) { + // find the encoding + stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); + + // is this a Unicode encoding? + if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { + stbtt_int32 slen = ttUSHORT(fc+loc+8); + stbtt_int32 off = ttUSHORT(fc+loc+10); + + // check if there's a prefix match + stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); + if (matchlen >= 0) { + // check for target_id+1 immediately following, with same encoding & language + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); + if (slen == 0) { + if (matchlen == nlen) + return 1; + } else if (matchlen < nlen && name[matchlen] == ' ') { + ++matchlen; + if (stbtt_CompareUTF8toUTF16_bigendian((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + return 1; + } + } else { + // if nothing immediately following + if (matchlen == nlen) + return 1; + } + } + } + + // @TODO handle other encodings + } + } + return 0; +} + +static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) +{ + stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); + stbtt_uint32 nm,hd; + if (!stbtt__isfont(fc+offset)) return 0; + + // check italics/bold/underline flags in macStyle... + if (flags) { + hd = stbtt__find_table(fc, offset, "head"); + if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; + } + + nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return 0; + + if (flags) { + // if we checked the macStyle flags, then just check the family and ignore the subfamily + if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } else { + if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } + + return 0; +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags) +{ + stbtt_int32 i; + for (i=0;;++i) { + stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); + if (off < 0) return off; + if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) + return off; + } +} + +#endif // STB_TRUETYPE_IMPLEMENTATION diff --git a/foreign/x64/freetype.lib b/foreign/x64/freetype.lib new file mode 100644 index 0000000..caf7dca Binary files /dev/null and b/foreign/x64/freetype.lib differ diff --git a/foreign/x64/libfreetype-mac.a b/foreign/x64/libfreetype-mac.a new file mode 100644 index 0000000..180adef Binary files /dev/null and b/foreign/x64/libfreetype-mac.a differ diff --git a/foreign/x86/freetype.lib b/foreign/x86/freetype.lib new file mode 100644 index 0000000..43f135c Binary files /dev/null and b/foreign/x86/freetype.lib differ diff --git a/foreign/x86/libfreetype-mac.a b/foreign/x86/libfreetype-mac.a new file mode 100644 index 0000000..d1e0c40 Binary files /dev/null and b/foreign/x86/libfreetype-mac.a differ diff --git a/res/4coder_icon.ico b/res/4coder_icon.ico new file mode 100644 index 0000000..141c7eb Binary files /dev/null and b/res/4coder_icon.ico differ diff --git a/res/icon.rc b/res/icon.rc new file mode 100644 index 0000000..3b70c83 --- /dev/null +++ b/res/icon.rc @@ -0,0 +1 @@ +main ICON 4coder_icon.ico diff --git a/res/icon.res b/res/icon.res new file mode 100644 index 0000000..dded693 Binary files /dev/null and b/res/icon.res differ diff --git a/res/small_icon.res b/res/small_icon.res new file mode 100644 index 0000000..314c5ec --- /dev/null +++ b/res/small_icon.res @@ -0,0 +1 @@ +Nonsense \ No newline at end of file diff --git a/site_resources/4coder_icon.ico b/site_resources/4coder_icon.ico new file mode 100644 index 0000000..141c7eb Binary files /dev/null and b/site_resources/4coder_icon.ico differ diff --git a/site_resources/4coder_logo_low_green.png b/site_resources/4coder_logo_low_green.png new file mode 100644 index 0000000..681fcf1 Binary files /dev/null and b/site_resources/4coder_logo_low_green.png differ diff --git a/site_resources/screen_1.png b/site_resources/screen_1.png new file mode 100644 index 0000000..a0ebd6e Binary files /dev/null and b/site_resources/screen_1.png differ diff --git a/site_resources/screen_2.png b/site_resources/screen_2.png new file mode 100644 index 0000000..904ffd7 Binary files /dev/null and b/site_resources/screen_2.png differ diff --git a/site_resources/screen_3.png b/site_resources/screen_3.png new file mode 100644 index 0000000..0d3b62f Binary files /dev/null and b/site_resources/screen_3.png differ diff --git a/test_data/input_data/mkdir.txt b/test_data/input_data/mkdir.txt new file mode 100644 index 0000000..f4ad4e3 --- /dev/null +++ b/test_data/input_data/mkdir.txt @@ -0,0 +1,3 @@ +Put this here so git will actually make the directory :D + + diff --git a/test_data/lots_of_files/4coder_buffer_types.h b/test_data/lots_of_files/4coder_buffer_types.h new file mode 100644 index 0000000..26f25cf --- /dev/null +++ b/test_data/lots_of_files/4coder_buffer_types.h @@ -0,0 +1,89 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 23.02.2016 + * + * Types shared by custom and application + * + */ + +// TOP + +#ifndef FRED_BUFFER_TYPES_H +#define FRED_BUFFER_TYPES_H + +typedef struct Full_Cursor{ + int pos; + int line, character; + float unwrapped_x, unwrapped_y; + float wrapped_x, wrapped_y; +} Full_Cursor; + +typedef enum{ + buffer_seek_pos, + buffer_seek_wrapped_xy, + buffer_seek_unwrapped_xy, + buffer_seek_line_char +} Buffer_Seek_Type; + +typedef struct Buffer_Seek{ + Buffer_Seek_Type type; + union{ + struct { int pos; }; + struct { int round_down; float x, y; }; + struct { int line, character; }; + }; +} Buffer_Seek; + +static Buffer_Seek +seek_pos(int pos){ + Buffer_Seek result; + result.type = buffer_seek_pos; + result.pos = pos; + return(result); +} + +static Buffer_Seek +seek_wrapped_xy(float x, float y, int round_down){ + Buffer_Seek result; + result.type = buffer_seek_wrapped_xy; + result.x = x; + result.y = y; + result.round_down = round_down; + return(result); +} + +static Buffer_Seek +seek_unwrapped_xy(float x, float y, int round_down){ + Buffer_Seek result; + result.type = buffer_seek_unwrapped_xy; + result.x = x; + result.y = y; + result.round_down = round_down; + return(result); +} + +static Buffer_Seek +seek_xy(float x, float y, int round_down, int unwrapped){ + Buffer_Seek result; + result.type = unwrapped?buffer_seek_unwrapped_xy:buffer_seek_wrapped_xy; + result.x = x; + result.y = y; + result.round_down = round_down; + return(result); +} + +static Buffer_Seek +seek_line_char(int line, int character){ + Buffer_Seek result; + result.type = buffer_seek_line_char; + result.line = line; + result.character = character; + return(result); +} + + +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4coder_config.h b/test_data/lots_of_files/4coder_config.h new file mode 100644 index 0000000..9784c34 --- /dev/null +++ b/test_data/lots_of_files/4coder_config.h @@ -0,0 +1,87 @@ +/* "4cpp" Open C++ Parser v0.1: Config + no warranty implied; use at your own risk + +NOTES ON USE: + This file is used to configure 4cpp options at the begining of 4cpp files. + It is not meant to be used directly. +*/ + +#ifdef FCPP_NO_CRT +# ifndef FCPP_NO_MALLOC +# define FCPP_NO_MALLOC +# endif +# ifndef FCPP_NO_ASSERT +# define FCPP_NO_ASSERT +# endif +# ifndef FCPP_NO_STRING +# define FCPP_NO_STRING +# endif +#endif + +#ifdef FCPP_FORBID_MALLOC +# define FCPP_NO_MALLOC +#endif + +#ifndef FCPP_NO_MALLOC +# include <stdlib.h> +#endif + +#ifndef FCPP_NO_ASSERT +# include <assert.h> +#endif + +#ifndef FCPP_NO_STRING +# include <string.h> +#endif + +#ifndef FCPP_NO_MALLOC +# ifndef FCPP_GET_MEMORY +# define FCPP_GET_MEMORY malloc +# endif +# ifndef FCPP_FREE_MEMORY +# define FCPP_FREE_MEMORY free +# endif +#else +# ifndef FCPP_FORBID_MALLOC +# ifndef FCPP_GET_MEMORY +# error Missing definition for FCPP_GET_MEMORY +# endif +# ifndef FCPP_FREE_MEMORY +# error Missing definition for FCPP_FREE_MEMORY +# endif +# endif +#endif + +#ifndef FCPP_NO_ASSERT +# ifndef FCPP_ASSERT +# define FCPP_ASSERT assert +# endif +#else +# ifndef FCPP_ASSERT +# define FCPP_ASSERT(x) +# endif +#endif + +#ifndef FCPP_NO_STRING +# ifndef FCPP_MEM_COPY +# define FCPP_MEM_COPY memcpy +# endif +# ifndef FCPP_MEM_MOVE +# define FCPP_MEM_MOVE memmove +# endif +#endif + +#ifndef FCPP_LINK +# ifdef FCPP_EXTERN +# define FCPP_LINK extern +# else +# define FCPP_LINK static +# endif +#endif + +#ifndef DrBegin +#define DrBegin() switch (s.__pc__){ case 0:; +#define DrEnd() default: Assert(!"Invalid __pc__"); } +#define DrYield(pc, n) { s.__pc__ = pc; *state = s; return(n); case pc:; } +#define DrReturn(n) { s.__pc__ = -1; return(n); } +#endif \ No newline at end of file diff --git a/test_data/lots_of_files/4coder_custom.cpp b/test_data/lots_of_files/4coder_custom.cpp new file mode 100644 index 0000000..dca8651 --- /dev/null +++ b/test_data/lots_of_files/4coder_custom.cpp @@ -0,0 +1,1224 @@ +// Set which customization you want to use with this define or write your own +#define Custom_Current Custom_Default + +#define Custom_Default 0 + +// The following customization schemes are power users only: +#define Custom_HandmadeHero 1 + + +// TOP +#include "4coder_custom.h" + +#define FCPP_STRING_IMPLEMENTATION +#include "4coder_string.h" + +#define UseInterfacesThatArePhasingOut 0 +#include "4coder_helper.h" + +#ifndef literal +#define literal(s) (s), (sizeof(s)-1) +#endif + +// NOTE(allen|a3.3): All of your custom ids should be enumerated +// as shown here, they may start at 0, and you can only have +// 2^24 of them so don't be wasteful! +enum My_Maps{ + my_code_map +}; + +HOOK_SIG(my_start){ + exec_command(app, cmdid_open_panel_vsplit); + exec_command(app, cmdid_change_active_panel); + + app->change_theme(app, literal("4coder")); + app->change_font(app, literal("liberation sans")); + + // Theme options: + // "4coder" + // "Handmade Hero" + // "Twilight" + // "Woverine" + // "stb" + + // Font options: + // "liberation sans" + // "liberation mono" + // "hack" + // "cutive mono" + // "inconsolata" + + // no meaning for return + return(0); +} + +HOOK_SIG(my_file_settings){ + // NOTE(allen|a4): In hooks that want parameters, such as this file + // created hook. The file created hook is guaranteed to have only + // and exactly one buffer parameter. In normal command callbacks + // there are no parameter buffers. + Buffer_Summary buffer = app->get_parameter_buffer(app, 0); + assert(buffer.exists); + + int treat_as_code = 0; + + if (buffer.file_name && buffer.size < (16 << 20)){ + String ext = file_extension(make_string(buffer.file_name, buffer.file_name_len)); + if (match(ext, make_lit_string("cpp"))) treat_as_code = 1; + else if (match(ext, make_lit_string("h"))) treat_as_code = 1; + else if (match(ext, make_lit_string("c"))) treat_as_code = 1; + else if (match(ext, make_lit_string("hpp"))) treat_as_code = 1; + } + + push_parameter(app, par_lex_as_cpp_file, treat_as_code); + push_parameter(app, par_wrap_lines, !treat_as_code); + push_parameter(app, par_key_mapid, (treat_as_code)?((int)my_code_map):((int)mapid_file)); + exec_command(app, cmdid_set_settings); + + // no meaning for return + return(0); +} + +unsigned char blink_t = 0; + +HOOK_SIG(my_frame){ + // NOTE(allen|a4): Please use me sparingly! This get's called roughly once every *33 ms* if everything is going well. + // But if you start doing a lot in here, there's nothing 4codes does to stop you from making it a lot slower. + + int result = 0; + Theme_Color theme_color_1[] = { + {Stag_Cursor, 0x00FF00}, + {Stag_At_Cursor, 0x000000} + }; + + Theme_Color theme_color_2[2] = { + {Stag_Cursor, 0x000000}, + {Stag_At_Cursor, 0xFFFFFF} + }; + + Theme_Color *theme_color; + + ++blink_t; + + if (blink_t == 20 || blink_t == 40){ + if (blink_t == 20){ + theme_color = theme_color_2; + } + else{ + theme_color = theme_color_1; + blink_t = 0; + } + + result = 1; + app->set_theme_colors(app, theme_color, 2); + } + + // return non-zero if you do anything that might change the screen! + // 4coder won't redraw unless you tell it you've changed something important. + // If you redraw *all* the time it's going to slow 4coder down and increase power consumption. + return(result); +} + +static void +write_string(Application_Links *app, String string){ + Buffer_Summary buffer = app->get_active_buffer(app); + app->buffer_replace_range(app, &buffer, buffer.buffer_cursor_pos, buffer.buffer_cursor_pos, string.str, string.size); +} + +CUSTOM_COMMAND_SIG(write_increment){ + write_string(app, make_lit_string("++")); +} + +CUSTOM_COMMAND_SIG(write_decrement){ + write_string(app, make_lit_string("--")); +} + +CUSTOM_COMMAND_SIG(write_allen_todo){ + write_string(app, make_lit_string("// TODO(allen): ")); +} + +CUSTOM_COMMAND_SIG(write_allen_note){ + write_string(app, make_lit_string("// NOTE(allen): ")); +} + +static void +basic_seek(Application_Links *app, Command_ID seek_type, unsigned int flags){ + push_parameter(app, par_flags, flags); + exec_command(app, seek_type); +} + +#define SEEK_COMMAND(n, dir, flags)\ +CUSTOM_COMMAND_SIG(seek_##n##_##dir){\ + basic_seek(app, cmdid_seek_##dir, flags);\ +} + +SEEK_COMMAND(whitespace, right, BoundryWhitespace) +SEEK_COMMAND(whitespace, left, BoundryWhitespace) +SEEK_COMMAND(token, right, BoundryToken) +SEEK_COMMAND(token, left, BoundryToken) +SEEK_COMMAND(white_or_token, right, BoundryToken | BoundryWhitespace) +SEEK_COMMAND(white_or_token, left, BoundryToken | BoundryWhitespace) +SEEK_COMMAND(alphanumeric, right, BoundryAlphanumeric) +SEEK_COMMAND(alphanumeric, left, BoundryAlphanumeric) +SEEK_COMMAND(alphanumeric_or_camel, right, BoundryAlphanumeric | BoundryCamelCase) +SEEK_COMMAND(alphanumeric_or_camel, left, BoundryAlphanumeric | BoundryCamelCase) + +static void +long_braces(Application_Links *app, char *text, int size){ + View_Summary view; + Buffer_Summary buffer; + int pos; + + view = app->get_active_view(app); + buffer = app->get_buffer(app, view.buffer_id); + + pos = view.cursor.pos; + app->buffer_replace_range(app, &buffer, pos, pos, text, size); + app->view_set_cursor(app, &view, seek_pos(pos + 2), 1); + + push_parameter(app, par_range_start, pos); + push_parameter(app, par_range_end, pos + size); + push_parameter(app, par_clear_blank_lines, 0); + exec_command(app, cmdid_auto_tab_range); +} + +CUSTOM_COMMAND_SIG(open_long_braces){ + char text[] = "{\n\n}"; + int size = sizeof(text) - 1; + long_braces(app, text, size); +} + +CUSTOM_COMMAND_SIG(open_long_braces_semicolon){ + char text[] = "{\n\n};"; + int size = sizeof(text) - 1; + long_braces(app, text, size); +} + +CUSTOM_COMMAND_SIG(open_long_braces_break){ + char text[] = "{\n\n}break;"; + int size = sizeof(text) - 1; + long_braces(app, text, size); +} + +CUSTOM_COMMAND_SIG(paren_wrap){ + View_Summary view; + Buffer_Summary buffer; + + char text1[] = "("; + int size1 = sizeof(text1) - 1; + + char text2[] = ")"; + int size2 = sizeof(text2) - 1; + + Range range; + int pos; + + view = app->get_active_view(app); + buffer = app->get_active_buffer(app); + + range = get_range(&view); + pos = range.max; + app->buffer_replace_range(app, &buffer, pos, pos, text2, size2); + + pos = range.min; + app->buffer_replace_range(app, &buffer, pos, pos, text1, size1); +} + +CUSTOM_COMMAND_SIG(if0_off){ + View_Summary view; + Buffer_Summary buffer; + + char text1[] = "\n#if 0"; + int size1 = sizeof(text1) - 1; + + char text2[] = "#endif\n"; + int size2 = sizeof(text2) - 1; + + Range range; + int pos; + + view = app->get_active_view(app); + buffer = app->get_active_buffer(app); + + range = get_range(&view); + pos = range.min; + + app->buffer_replace_range(app, &buffer, pos, pos, text1, size1); + + push_parameter(app, par_range_start, pos); + push_parameter(app, par_range_end, pos); + exec_command(app, cmdid_auto_tab_range); + + app->refresh_view(app, &view); + range = get_range(&view); + pos = range.max; + + app->buffer_replace_range(app, &buffer, pos, pos, text2, size2); + + push_parameter(app, par_range_start, pos); + push_parameter(app, par_range_end, pos); + exec_command(app, cmdid_auto_tab_range); +} + +CUSTOM_COMMAND_SIG(backspace_word){ + View_Summary view; + Buffer_Summary buffer; + int pos2, pos1; + + view = app->get_active_view(app); + + pos2 = view.cursor.pos; + exec_command(app, seek_alphanumeric_left); + app->refresh_view(app, &view); + pos1 = view.cursor.pos; + + buffer = app->get_buffer(app, view.buffer_id); + app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0); +} + +CUSTOM_COMMAND_SIG(snipe_token_or_word){ + View_Summary view; + Buffer_Summary buffer; + int pos1, pos2; + + view = app->get_active_view(app); + + push_parameter(app, par_flags, BoundryToken | BoundryWhitespace); + exec_command(app, cmdid_seek_left); + app->refresh_view(app, &view); + pos1 = view.cursor.pos; + + push_parameter(app, par_flags, BoundryToken | BoundryWhitespace); + exec_command(app, cmdid_seek_right); + app->refresh_view(app, &view); + pos2 = view.cursor.pos; + + Range range = make_range(pos1, pos2); + buffer = app->get_buffer(app, view.buffer_id); + app->buffer_replace_range(app, &buffer, range.start, range.end, 0, 0); +} + +CUSTOM_COMMAND_SIG(switch_to_compilation){ + View_Summary view; + Buffer_Summary buffer; + + char name[] = "*compilation*"; + int name_size = sizeof(name)-1; + + view = app->get_active_view(app); + buffer = app->get_buffer_by_name(app, name, name_size); + + app->view_set_buffer(app, &view, buffer.buffer_id); +} + +CUSTOM_COMMAND_SIG(move_up_10){ + View_Summary view; + float x, y; + + view = app->get_active_view(app); + x = view.preferred_x; + + if (view.unwrapped_lines){ + y = view.cursor.unwrapped_y; + } + else{ + y = view.cursor.wrapped_y; + } + + y -= 10*view.line_height; + + app->view_set_cursor(app, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0); +} + +CUSTOM_COMMAND_SIG(move_down_10){ + View_Summary view; + float x, y; + + view = app->get_active_view(app); + x = view.preferred_x; + + if (view.unwrapped_lines){ + y = view.cursor.wrapped_y; + } + else{ + y = view.cursor.wrapped_y; + } + + y += 10*view.line_height; + + app->view_set_cursor(app, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0); +} + +CUSTOM_COMMAND_SIG(open_file_in_quotes){ + View_Summary view; + Buffer_Summary buffer; + char short_file_name[128]; + int pos, start, end, size; + + view = app->get_active_view(app); + buffer = app->get_buffer(app, view.buffer_id); + pos = view.cursor.pos; + app->buffer_seek_delimiter(app, &buffer, pos, '"', 1, &end); + app->buffer_seek_delimiter(app, &buffer, pos, '"', 0, &start); + + ++start; + size = end - start; + + // NOTE(allen): This check is necessary because app->buffer_read_range + // requiers that the output buffer you provide is at least (end - start) bytes long. + if (size < sizeof(short_file_name)){ + char file_name_[256]; + String file_name = make_fixed_width_string(file_name_); + + app->buffer_read_range(app, &buffer, start, end, short_file_name); + + copy(&file_name, make_string(buffer.file_name, buffer.file_name_len)); + remove_last_folder(&file_name); + append(&file_name, make_string(short_file_name, size)); + + exec_command(app, cmdid_change_active_panel); + push_parameter(app, par_name, expand_str(file_name)); + exec_command(app, cmdid_interactive_open); + } +} + +CUSTOM_COMMAND_SIG(goto_line){ + int line_number; + Query_Bar bar; + char string_space[256]; + + bar.prompt = make_lit_string("Goto Line: "); + bar.string = make_fixed_width_string(string_space); + + if (query_user_number(app, &bar)){ + line_number = str_to_int(bar.string); + active_view_to_line(app, line_number); + } +} + +CUSTOM_COMMAND_SIG(search); +CUSTOM_COMMAND_SIG(reverse_search); + +static void +isearch(Application_Links *app, int start_reversed){ + View_Summary view; + Buffer_Summary buffer; + User_Input in; + Query_Bar bar; + + if (app->start_query_bar(app, &bar, 0) == 0) return; + + Range match; + int reverse = start_reversed; + int pos; + + view = app->get_active_view(app); + buffer = app->get_buffer(app, view.buffer_id); + + pos = view.cursor.pos; + match = make_range(pos, pos); + + char bar_string_space[256]; + bar.string = make_fixed_width_string(bar_string_space); + + String isearch = make_lit_string("I-Search: "); + String rsearch = make_lit_string("Reverse-I-Search: "); + + while (1){ + // NOTE(allen): Change the bar's prompt to match the current direction. + if (reverse) bar.prompt = rsearch; + else bar.prompt = isearch; + + in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton); + if (in.abort) break; + + // NOTE(allen): If we're getting mouse events here it's a 4coder bug, because we + // only asked to intercept key events. + assert(in.type == UserInputKey); + + int made_change = 0; + if (in.key.keycode == '\n' || in.key.keycode == '\t'){ + break; + } + else if (in.key.character && key_is_unmodified(&in.key)){ + append(&bar.string, in.key.character); + made_change = 1; + } + else if (in.key.keycode == key_back){ + --bar.string.size; + made_change = 1; + } + + int step_forward = 0; + int step_backward = 0; + + if (CommandEqual(in.command, search) || + in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1; + if (CommandEqual(in.command, reverse_search) || + in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1; + + int start_pos = pos; + if (step_forward && reverse){ + start_pos = match.start + 1; + pos = start_pos; + reverse = 0; + step_forward = 0; + } + if (step_backward && !reverse){ + start_pos = match.start - 1; + pos = start_pos; + reverse = 1; + step_backward = 0; + } + + if (in.key.keycode != key_back){ + int new_pos; + if (reverse){ + app->buffer_seek_string(app, &buffer, start_pos - 1, bar.string.str, bar.string.size, 0, &new_pos); + if (new_pos >= 0){ + if (step_backward){ + pos = new_pos; + start_pos = new_pos; + app->buffer_seek_string(app, &buffer, start_pos - 1, bar.string.str, bar.string.size, 0, &new_pos); + if (new_pos < 0) new_pos = start_pos; + } + match.start = new_pos; + match.end = match.start + bar.string.size; + } + } + else{ + app->buffer_seek_string(app, &buffer, start_pos + 1, bar.string.str, bar.string.size, 1, &new_pos); + if (new_pos < buffer.size){ + if (step_forward){ + pos = new_pos; + start_pos = new_pos; + app->buffer_seek_string(app, &buffer, start_pos + 1, bar.string.str, bar.string.size, 1, &new_pos); + if (new_pos >= buffer.size) new_pos = start_pos; + } + match.start = new_pos; + match.end = match.start + bar.string.size; + } + } + } + else{ + match.end = match.start + bar.string.size; + } + + app->view_set_highlight(app, &view, match.start, match.end, 1); + } + app->view_set_highlight(app, &view, 0, 0, 0); + if (in.abort) return; + + app->view_set_cursor(app, &view, seek_pos(match.min), 1); +} + +CUSTOM_COMMAND_SIG(search){ + isearch(app, 0); +} + +CUSTOM_COMMAND_SIG(reverse_search){ + isearch(app, 1); +} + +CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ + View_Summary view; + Buffer_Summary buffer; + Range range; + String string; + int is_first, i; + + exec_command(app, seek_token_left); + view = app->get_active_view(app); + range.min = view.cursor.pos; + + exec_command(app, seek_token_right); + app->refresh_view(app, &view); + range.max = view.cursor.pos; + + string.str = (char*)app->memory; + string.size = range.max - range.min; + assert(string.size < app->memory_size); + + buffer = app->get_buffer(app, view.buffer_id); + app->buffer_read_range(app, &buffer, range.min, range.max, string.str); + + is_first = 1; + for (i = 0; i < string.size; ++i){ + if (char_is_alpha_true(string.str[i])){ + if (is_first) is_first = 0; + else string.str[i] = char_to_lower(string.str[i]); + } + else{ + is_first = 1; + } + } + + app->buffer_replace_range(app, &buffer, range.min, range.max, string.str, string.size); +} + +// TODO(allen): +// get range by specific "word" type (for example "get token range") +// read range by specific "word" type +// Dream API for rewrite_as_single_caps: +#if 0 +{ + rewrite = get_rewrite(app, ByToken); + string = get_rewrite_string(app, &rewrite, app->memory, app->memory_size); + + is_first = 1; + for (i = 0; i < string.size; ++i){ + if (char_is_alpha_true(string.str[i])){ + if (is_first) is_first = 0; + else string.str[i] = char_to_lower(string.str[i]); + } + else{ + is_first = 1; + } + } + + do_rewrite(app, &rewrite, string); +} +#endif + +CUSTOM_COMMAND_SIG(replace_in_range){ + Query_Bar replace; + char replace_space[1024]; + replace.prompt = make_lit_string("Replace: "); + replace.string = make_fixed_width_string(replace_space); + + Query_Bar with; + char with_space[1024]; + with.prompt = make_lit_string("With: "); + with.string = make_fixed_width_string(with_space); + + if (!query_user_string(app, &replace)) return; + if (replace.string.size == 0) return; + + if (!query_user_string(app, &with)) return; + + String r, w; + r = replace.string; + w = with.string; + + Buffer_Summary buffer; + View_Summary view; + + view = app->get_active_view(app); + buffer = app->get_buffer(app, view.buffer_id); + + Range range = get_range(&view); + + int pos, new_pos; + pos = range.min; + app->buffer_seek_string(app, &buffer, pos, r.str, r.size, 1, &new_pos); + + while (new_pos + r.size < range.end){ + app->buffer_replace_range(app, &buffer, new_pos, new_pos + r.size, w.str, w.size); + range = get_range(&view); + pos = new_pos + w.size; + app->buffer_seek_string(app, &buffer, pos, r.str, r.size, 1, &new_pos); + } +} + +CUSTOM_COMMAND_SIG(query_replace){ + Query_Bar replace; + char replace_space[1024]; + replace.prompt = make_lit_string("Replace: "); + replace.string = make_fixed_width_string(replace_space); + + Query_Bar with; + char with_space[1024]; + with.prompt = make_lit_string("With: "); + with.string = make_fixed_width_string(with_space); + + if (!query_user_string(app, &replace)) return; + if (replace.string.size == 0) return; + + if (!query_user_string(app, &with)) return; + + String r, w; + r = replace.string; + w = with.string; + + Query_Bar bar; + Buffer_Summary buffer; + View_Summary view; + int pos, new_pos; + + bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n"); + bar.string = empty_string(); + + app->start_query_bar(app, &bar, 0); + + view = app->get_active_view(app); + buffer = app->get_buffer(app, view.buffer_id); + + pos = view.cursor.pos; + app->buffer_seek_string(app, &buffer, pos, r.str, r.size, 1, &new_pos); + + User_Input in = {0}; + while (new_pos < buffer.size){ + Range match = make_range(new_pos, new_pos + r.size); + app->view_set_highlight(app, &view, match.min, match.max, 1); + + in = app->get_user_input(app, EventOnAnyKey, EventOnButton); + if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break; + + if (in.key.character == 'y' || in.key.character == 'Y' || in.key.character == '\n' || in.key.character == '\t'){ + app->buffer_replace_range(app, &buffer, match.min, match.max, w.str, w.size); + pos = match.start + w.size; + } + else{ + pos = match.max; + } + + app->buffer_seek_string(app, &buffer, pos, r.str, r.size, 1, &new_pos); + } + + app->view_set_highlight(app, &view, 0, 0, 0); + if (in.abort) return; + + app->view_set_cursor(app, &view, seek_pos(pos), 1); +} + +CUSTOM_COMMAND_SIG(close_all_code){ + String extension; + Buffer_Summary buffer; + + for (buffer = app->get_buffer_first(app); + buffer.exists; + app->get_buffer_next(app, &buffer)){ + + extension = file_extension(make_string(buffer.file_name, buffer.file_name_len)); + if (match(extension, make_lit_string("cpp")) || + match(extension, make_lit_string("hpp")) || + match(extension, make_lit_string("c")) || + match(extension, make_lit_string("h"))){ + // + push_parameter(app, par_buffer_id, buffer.buffer_id); + exec_command(app, cmdid_kill_buffer); + } + } +} + +CUSTOM_COMMAND_SIG(open_all_code){ + // NOTE(allen|a3.4.4): This method of getting the hot directory works + // because this custom.cpp gives no special meaning to app->memory + // and doesn't set up a persistent allocation system within app->memory. + // push_directory isn't a very good option since it's tied to the parameter + // stack, so I am phasing that idea out now. + String dir = make_string(app->memory, 0, app->memory_size); + dir.size = app->directory_get_hot(app, dir.str, dir.memory_size); + int dir_size = dir.size; + + // NOTE(allen|a3.4.4): Here we get the list of files in this directory. + // Notice that we free_file_list at the end. + File_List list = app->get_file_list(app, dir.str, dir.size); + + for (int i = 0; i < list.count; ++i){ + File_Info *info = list.infos + i; + if (!info->folder){ + String extension = file_extension(info->filename); + if (match(extension, make_lit_string("cpp")) || + match(extension, make_lit_string("hpp")) || + match(extension, make_lit_string("c")) || + match(extension, make_lit_string("h"))){ + // NOTE(allen): There's no way in the 4coder API to use relative + // paths at the moment, so everything should be full paths. Which is + // managable. Here simply set the dir string size back to where it + // was originally, so that new appends overwrite old ones. + dir.size = dir_size; + append(&dir, info->filename); + push_parameter(app, par_name, dir.str, dir.size); + //push_parameter(app, par_do_in_background, 1); + exec_command(app, cmdid_interactive_open); + } + } + } + + app->free_file_list(app, list); +} + +CUSTOM_COMMAND_SIG(execute_any_cli){ + Query_Bar bar_out, bar_cmd; + String hot_directory; + char space[1024], more_space[1024], even_more_space[1024]; + + bar_out.prompt = make_lit_string("Output Buffer: "); + bar_out.string = make_fixed_width_string(space); + if (!query_user_string(app, &bar_out)) return; + + bar_cmd.prompt = make_lit_string("Command: "); + bar_cmd.string = make_fixed_width_string(more_space); + if (!query_user_string(app, &bar_cmd)) return; + + hot_directory = make_fixed_width_string(even_more_space); + hot_directory.size = app->directory_get_hot(app, hot_directory.str, hot_directory.memory_size); + + push_parameter(app, par_flags, CLI_OverlapWithConflict); + push_parameter(app, par_name, bar_out.string.str, bar_out.string.size); + push_parameter(app, par_cli_path, hot_directory.str, hot_directory.size); + push_parameter(app, par_cli_command, bar_cmd.string.str, bar_cmd.string.size); + exec_command(app, cmdid_command_line); +} + +CUSTOM_COMMAND_SIG(execute_arbitrary_command){ + // NOTE(allen): This isn't a super powerful version of this command, I will expand + // upon it so that it has all the cmdid_* commands by default. However, with this + // as an example you have everything you need to make it work already. You could + // even use app->memory to create a hash table in the start hook. + Query_Bar bar; + char space[1024]; + bar.prompt = make_lit_string("Command: "); + bar.string = make_fixed_width_string(space); + + if (!query_user_string(app, &bar)) return; + + // NOTE(allen): Here I chose to end this query bar because when I call another + // command it might ALSO have query bars and I don't want this one hanging + // around at that point. Since the bar exists on my stack the result of the query + // is still available in bar.string though. + app->end_query_bar(app, &bar, 0); + + if (match(bar.string, make_lit_string("open all code"))){ + exec_command(app, open_all_code); + } + else if(match(bar.string, make_lit_string("close all code"))){ + exec_command(app, close_all_code); + } + else if (match(bar.string, make_lit_string("open menu"))){ + exec_command(app, cmdid_open_menu); + } + else if (match(bar.string, make_lit_string("dos lines"))){ + exec_command(app, cmdid_eol_dosify); + } + else if (match(bar.string, make_lit_string("nix lines"))){ + exec_command(app, cmdid_eol_nixify); + } + else{ + // TODO(allen): feedback message + } +} + +CUSTOM_COMMAND_SIG(open_in_other){ + exec_command(app, cmdid_change_active_panel); + exec_command(app, cmdid_interactive_open); +} + +CUSTOM_COMMAND_SIG(open_my_files){ + // NOTE(allen|a3.1): EXAMPLE probably not useful in practice. + // + // The command cmdid_interactive_open can now open + // a file specified on the parameter stack. If the file does not exist + // cmdid_interactive_open behaves as usual. If par_do_in_background + // is set to true the command is prevented from changing the view under + // any circumstance. + push_parameter(app, par_name, literal("w:/4ed/data/test/basic.cpp")); + exec_command(app, cmdid_interactive_open); + + exec_command(app, cmdid_change_active_panel); + + char my_file[256]; + int my_file_len; + + my_file_len = sizeof("w:/4ed/data/test/basic.txt") - 1; + for (int i = 0; i < my_file_len; ++i){ + my_file[i] = ("w:/4ed/data/test/basic.txt")[i]; + } + + // NOTE(allen|a3.1): null terminators are not needed for strings. + push_parameter(app, par_name, my_file, my_file_len); + exec_command(app, cmdid_interactive_open); + + exec_command(app, cmdid_change_active_panel); +} + +CUSTOM_COMMAND_SIG(build_at_launch_location){ + // NOTE(allen|a3.3): EXAMPLE probably not all that useful in practice. + // + // An example of calling build by setting all + // parameters directly. This only works if build.bat can be called + // from the directory the application is launched at. + push_parameter(app, par_flags, CLI_OverlapWithConflict); + push_parameter(app, par_name, literal("*compilation*")); + push_parameter(app, par_cli_path, literal(".")); + push_parameter(app, par_cli_command, literal("build")); + exec_command(app, cmdid_command_line); +} + +CUSTOM_COMMAND_SIG(build_search){ + // NOTE(allen|a3.3): An example of traversing the filesystem through parent + // directories looking for a file, in this case a batch file to execute. + // + // + // Step 1: Grab all of the user memory (or, you know, less if you've got better + // thing to do with some of it). Make a string and store the hot directory in it. + // + // Step 2: app->file_exists queries the file system to see if "<somedir>/build.bat" exists. + // If it does exist several parameters are pushed and cmdid_command_line is executed: + // - par_flags: flags for specifiying behaviors + // CLI_OverlapWithConflict - (on by default) if another CLI is still using the output buffer + // that process is detached from the buffer and this process executes outputing to the buffer + // CLI_AlwaysBindToView - if set, the current view always switches to the output buffer + // even if the output buffer is open in another view + // + // - par_name: the name of the buffer to fill with the output from the process + // - par_buffer_id: the buffer_id of the buffer to to fill with output + // If both are set buffer_id is used and the name is ignored. + // If neither is set the command runs without storing output anywhere. + // + // - par_cli_path: sets the path from which the command is executed + // If this parameter is unset the command runs from the hot directory. + // + // - par_cli_command: sets the actual command to be executed, this can be almost any + // command that you could execute through a command line interface. + // If this parameter is unset the command get's it's command from the range between + // the mark and cursor. + // + // Step 3: If the batch file did not exist change the dir string to the parent directory using + // app->directory_cd. The cd function can also be used to navigate to subdirectories. + // It returns true if it can actually move in the specified direction, and false otherwise. + // + // This doesn't actually change the hot directory of 4coder, it's only effect is to + // modify the string you passed in to reflect the change in directory if that change was possible. + + int keep_going = 1; + int old_size; + String dir = make_string(app->memory, 0, app->memory_size); + dir.size = app->directory_get_hot(app, dir.str, dir.memory_size); + + while (keep_going){ + old_size = dir.size; + append(&dir, "build.bat"); + + if (app->file_exists(app, dir.str, dir.size)){ + dir.size = old_size; + + push_parameter(app, par_flags, CLI_OverlapWithConflict); + push_parameter(app, par_name, literal("*compilation*")); + push_parameter(app, par_cli_path, dir.str, dir.size); + + if (append(&dir, "build")){ + push_parameter(app, par_cli_command, dir.str, dir.size); + exec_command(app, cmdid_command_line); + } + else{ + app->clear_parameters(app); + } + + return; + } + dir.size = old_size; + + if (app->directory_cd(app, dir.str, &dir.size, dir.memory_size, literal("..")) == 0){ + keep_going = 0; + } + } + + // TODO(allen): feedback message - couldn't find build.bat +} + +CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){ + View_Summary view = app->get_active_view(app); + push_parameter(app, par_range_start, view.cursor.pos); + push_parameter(app, par_range_end, view.cursor.pos); + push_parameter(app, par_clear_blank_lines, 0); + exec_command(app, cmdid_auto_tab_range); +} + +CUSTOM_COMMAND_SIG(auto_tab_whole_file){ + Buffer_Summary buffer = app->get_active_buffer(app); + push_parameter(app, par_range_start, 0); + push_parameter(app, par_range_end, buffer.size); + exec_command(app, cmdid_auto_tab_range); +} + +CUSTOM_COMMAND_SIG(write_and_auto_tab){ + exec_command(app, cmdid_write_character); + exec_command(app, auto_tab_line_at_cursor); +} + +// NOTE(allen|a4) See 4coder_styles.h for a list of available style tags. +// There are style tags corresponding to every color in the theme editor. +CUSTOM_COMMAND_SIG(improve_theme){ + Theme_Color colors[] = { + {Stag_Bar, 0xFF0088}, + {Stag_Margin, 0x880088}, + {Stag_Margin_Hover, 0xAA0088}, + {Stag_Margin_Active, 0xDD0088}, + {Stag_Cursor, 0xFF0000}, + }; + + int count = ArrayCount(colors); + + app->set_theme_colors(app, colors, count); +} + +CUSTOM_COMMAND_SIG(ruin_theme){ + Theme_Color colors[] = { + {Stag_Bar, 0x888888}, + {Stag_Margin, 0x181818}, + {Stag_Margin_Hover, 0x252525}, + {Stag_Margin_Active, 0x323232}, + {Stag_Cursor, 0x00EE00}, + }; + + int count = ArrayCount(colors); + + app->set_theme_colors(app, colors, count); +} + +// NOTE(allen|a4): scroll rule information +// +// The parameters: +// target_x, target_y +// This is where the view would like to be for the purpose of +// following the cursor, doing mouse wheel work, etc. +// +// scroll_x, scroll_y +// These are pointers to where the scrolling actually is. If you bind +// the scroll rule it is you have to update these in some way to move +// the actual location of the scrolling. +// +// view_id +// This corresponds to which view is computing it's new scrolling position. +// This id DOES correspond to the views that View_Summary contains. +// This will always be between 1 and 16 (0 is a null id). +// See below for an example of having state that carries across scroll udpates. +// +// is_new_target +// If the target of the view is different from the last target in either x or y +// this is true, otherwise it is false. +// +// The return: +// Should be true if and only if scroll_x or scroll_y are changed. +// +// Don't try to use the app pointer in a scroll rule, you're asking for trouble. +// +// If you don't bind scroll_rule, nothing bad will happen, yo will get default +// 4coder scrolling behavior. +// + +struct Scroll_Velocity{ + float x, y; +}; + +Scroll_Velocity scroll_velocity_[16] = {0}; +Scroll_Velocity *scroll_velocity = scroll_velocity_ - 1; + +static int +smooth_camera_step(float target, float *current, float *vel, float S, float T){ + int result = 0; + float curr = *current; + float v = *vel; + if (curr != target){ + if (curr > target - .1f && curr < target + .1f){ + curr = target; + v = 1.f; + } + else{ + float L = curr + T*(target - curr); + + int sign = (target > curr) - (target < curr); + float V = curr + sign*v; + + if (sign > 0) curr = (L<V)?(L):(V); + else curr = (L>V)?(L):(V); + + if (curr == V){ + v *= S; + } + } + + *current = curr; + *vel = v; + result = 1; + } + return result; +} + +SCROLL_RULE_SIG(smooth_scroll_rule){ + Scroll_Velocity *velocity = scroll_velocity + view_id; + int result = 0; + if (velocity->x == 0.f){ + velocity->x = 1.f; + velocity->y = 1.f; + } + + if (smooth_camera_step(target_y, scroll_y, &velocity->y, 40.f, 1.f/4.f)){ + result = 1; + } + if (smooth_camera_step(target_x, scroll_x, &velocity->x, 40.f, 1.f/4.f)){ + result = 1; + } + + return(result); +} + +#if Custom_Current == Custom_HandmadeHero +# include "power/4coder_handmade_hero.cpp" +#endif + +extern "C" GET_BINDING_DATA(get_bindings){ + Bind_Helper context_actual = begin_bind_helper(data, size); + Bind_Helper *context = &context_actual; + +#if Custom_Current == Custom_HandmadeHero + casey_get_bindings(context); +#else + + // NOTE(allen|a3.1): Hooks have no loyalties to maps. All hooks are global + // and once set they always apply, regardless of what map is active. + set_hook(context, hook_start, my_start); + set_hook(context, hook_open_file, my_file_settings); + //set_hook(context, hook_frame, my_frame); // Example of a frame hook, but disabled by default. + + set_scroll_rule(context, smooth_scroll_rule); + + begin_map(context, mapid_global); + + bind(context, 'p', MDFR_CTRL, cmdid_open_panel_vsplit); + bind(context, '_', MDFR_CTRL, cmdid_open_panel_hsplit); + bind(context, 'P', MDFR_CTRL, cmdid_close_panel); + bind(context, 'n', MDFR_CTRL, cmdid_interactive_new); + bind(context, 'o', MDFR_CTRL, cmdid_interactive_open); + bind(context, ',', MDFR_CTRL, cmdid_change_active_panel); + bind(context, 'k', MDFR_CTRL, cmdid_interactive_kill_buffer); + bind(context, 'i', MDFR_CTRL, cmdid_interactive_switch_buffer); + bind(context, 'c', MDFR_ALT, cmdid_open_color_tweaker); + bind(context, 'o', MDFR_ALT, open_in_other); + + bind(context, 'm', MDFR_ALT, build_search); + bind(context, ',', MDFR_ALT, switch_to_compilation); + bind(context, 'x', MDFR_ALT, execute_arbitrary_command); + bind(context, 'z', MDFR_ALT, execute_any_cli); + + // NOTE(allen): These callbacks may not actually be useful to you, but + // go look at them and see what they do. + bind(context, 'M', MDFR_ALT | MDFR_CTRL, open_my_files); + bind(context, 'M', MDFR_ALT, build_at_launch_location); + + bind(context, '`', MDFR_ALT, improve_theme); + bind(context, '~', MDFR_ALT, ruin_theme); + + end_map(context); + + + begin_map(context, my_code_map); + + // NOTE(allen|a3.1): Set this map (my_code_map == mapid_user_custom) to + // inherit from mapid_file. When searching if a key is bound + // in this map, if it is not found here it will then search mapid_file. + // + // If this is not set, it defaults to mapid_global. + inherit_map(context, mapid_file); + + // NOTE(allen|a3.1): Children can override parent's bindings. + bind(context, key_right, MDFR_CTRL, seek_alphanumeric_or_camel_right); + bind(context, key_left, MDFR_CTRL, seek_alphanumeric_or_camel_left); + + // NOTE(allen|a3.2): Specific keys can override vanilla keys, + // and write character writes whichever character corresponds + // to the key that triggered the command. + bind(context, '\n', MDFR_NONE, write_and_auto_tab); + bind(context, '}', MDFR_NONE, write_and_auto_tab); + bind(context, ')', MDFR_NONE, write_and_auto_tab); + bind(context, ']', MDFR_NONE, write_and_auto_tab); + bind(context, ';', MDFR_NONE, write_and_auto_tab); + bind(context, '#', MDFR_NONE, write_and_auto_tab); + + bind(context, '\t', MDFR_NONE, cmdid_word_complete); + bind(context, '\t', MDFR_CTRL, cmdid_auto_tab_range); + bind(context, '\t', MDFR_SHIFT, auto_tab_line_at_cursor); + + bind(context, '=', MDFR_CTRL, write_increment); + bind(context, '-', MDFR_CTRL, write_decrement); + bind(context, 't', MDFR_ALT, write_allen_todo); + bind(context, 'n', MDFR_ALT, write_allen_note); + bind(context, '[', MDFR_CTRL, open_long_braces); + bind(context, '{', MDFR_CTRL, open_long_braces_semicolon); + bind(context, '}', MDFR_CTRL, open_long_braces_break); + bind(context, '9', MDFR_CTRL, paren_wrap); + bind(context, 'i', MDFR_ALT, if0_off); + bind(context, '1', MDFR_ALT, open_file_in_quotes); + + end_map(context); + + + begin_map(context, mapid_file); + + // NOTE(allen|a3.4.4): Binding this essentially binds + // all key combos that would normally insert a character + // into a buffer. If the code for the key is not an enum + // value such as key_left or key_back then it is a vanilla key. + // It is possible to override this binding for individual keys. + bind_vanilla_keys(context, cmdid_write_character); + + bind(context, key_left, MDFR_NONE, cmdid_move_left); + bind(context, key_right, MDFR_NONE, cmdid_move_right); + bind(context, key_del, MDFR_NONE, cmdid_delete); + bind(context, key_back, MDFR_NONE, cmdid_backspace); + bind(context, key_up, MDFR_NONE, cmdid_move_up); + bind(context, key_down, MDFR_NONE, cmdid_move_down); + bind(context, key_end, MDFR_NONE, cmdid_seek_end_of_line); + bind(context, key_home, MDFR_NONE, cmdid_seek_beginning_of_line); + bind(context, key_page_up, MDFR_NONE, cmdid_page_up); + bind(context, key_page_down, MDFR_NONE, cmdid_page_down); + + bind(context, key_right, MDFR_CTRL, seek_whitespace_right); + bind(context, key_left, MDFR_CTRL, seek_whitespace_left); + bind(context, key_up, MDFR_CTRL, cmdid_seek_whitespace_up); + bind(context, key_down, MDFR_CTRL, cmdid_seek_whitespace_down); + + bind(context, key_up, MDFR_ALT, move_up_10); + bind(context, key_down, MDFR_ALT, move_down_10); + + bind(context, key_back, MDFR_CTRL, backspace_word); + bind(context, key_back, MDFR_ALT, snipe_token_or_word); + + bind(context, ' ', MDFR_CTRL, cmdid_set_mark); + bind(context, 'm', MDFR_CTRL, cmdid_cursor_mark_swap); + bind(context, 'c', MDFR_CTRL, cmdid_copy); + bind(context, 'x', MDFR_CTRL, cmdid_cut); + bind(context, 'v', MDFR_CTRL, cmdid_paste); + bind(context, 'V', MDFR_CTRL, cmdid_paste_next); + bind(context, 'Z', MDFR_CTRL, cmdid_timeline_scrub); + bind(context, 'z', MDFR_CTRL, cmdid_undo); + bind(context, 'y', MDFR_CTRL, cmdid_redo); + bind(context, 'h', MDFR_CTRL, cmdid_history_backward); + bind(context, 'H', MDFR_CTRL, cmdid_history_forward); + bind(context, 'd', MDFR_CTRL, cmdid_delete_range); + bind(context, 'l', MDFR_CTRL, cmdid_toggle_line_wrap); + bind(context, 'L', MDFR_CTRL, cmdid_toggle_endline_mode); + bind(context, 'u', MDFR_CTRL, cmdid_to_uppercase); + bind(context, 'j', MDFR_CTRL, cmdid_to_lowercase); + bind(context, '?', MDFR_CTRL, cmdid_toggle_show_whitespace); + + bind(context, '~', MDFR_CTRL, cmdid_clean_all_lines); + bind(context, '1', MDFR_CTRL, cmdid_eol_dosify); + bind(context, '!', MDFR_CTRL, cmdid_eol_nixify); + + bind(context, 'f', MDFR_CTRL, search); + bind(context, 'r', MDFR_CTRL, reverse_search); + bind(context, 'g', MDFR_CTRL, goto_line); + bind(context, 'q', MDFR_CTRL, query_replace); + bind(context, 'a', MDFR_CTRL, replace_in_range); + bind(context, 's', MDFR_ALT, rewrite_as_single_caps); + + bind(context, 'K', MDFR_CTRL, cmdid_kill_buffer); + bind(context, 'O', MDFR_CTRL, cmdid_reopen); + bind(context, 'w', MDFR_CTRL, cmdid_interactive_save_as); + bind(context, 's', MDFR_CTRL, cmdid_save); + + bind(context, '\n', MDFR_SHIFT, write_and_auto_tab); + bind(context, ' ', MDFR_SHIFT, cmdid_write_character); + + end_map(context); +#endif + + end_bind_helper(context); + + return context->write_total; +} + + diff --git a/test_data/lots_of_files/4coder_custom.h b/test_data/lots_of_files/4coder_custom.h new file mode 100644 index 0000000..ac2a8bb --- /dev/null +++ b/test_data/lots_of_files/4coder_custom.h @@ -0,0 +1,587 @@ + +#include "4coder_version.h" +#include "4coder_keycodes.h" +#include "4coder_style.h" +#include "4coder_buffer_types.h" + +#ifndef FRED_STRING_STRUCT +#define FRED_STRING_STRUCT +typedef struct String{ + char *str; + int size; + int memory_size; +} String; + +typedef struct Offset_String{ + int offset; + int size; +} Offset_String; +#endif + +typedef unsigned char Code; + +typedef enum{ + MDFR_SHIFT_INDEX, + MDFR_CONTROL_INDEX, + MDFR_ALT_INDEX, + MDFR_CAPS_INDEX, + // always last + MDFR_INDEX_COUNT +} Key_Control; + +typedef struct Key_Event_Data{ + Code keycode; + Code character; + Code character_no_caps_lock; + + char modifiers[MDFR_INDEX_COUNT]; +} Key_Event_Data; + +typedef struct Mouse_State{ + char l, r; + char press_l, press_r; + char release_l, release_r; + char wheel; + char out_of_window; + int x, y; +} Mouse_State; + + +typedef union Range{ + struct{ + int min, max; + }; + struct{ + int start, end; + }; +} Range; + +inline Range +make_range(int p1, int p2){ + Range range; + if (p1 < p2){ + range.min = p1; + range.max = p2; + } + else{ + range.min = p2; + range.max = p1; + } + return(range); +} + + +typedef enum Dynamic_Type{ + dynamic_type_int, + dynamic_type_string, + // never below this + dynamic_type_count +} Dynamic_Type; + +typedef struct Dynamic{ + int type; + union{ + struct{ + int str_len; + char *str_value; + }; + int int_value; + }; +} Dynamic; + +inline Dynamic +dynamic_int(int x){ + Dynamic result; + result.type = dynamic_type_int; + result.int_value = x; + return result; +} + +inline Dynamic +dynamic_string(const char *string, int len){ + Dynamic result; + result.type = dynamic_type_string; + result.str_len = len; + result.str_value = (char*)(string); + return result; +} + +inline int +dynamic_to_int(Dynamic *dynamic){ + int result = 0; + if (dynamic->type == dynamic_type_int){ + result = dynamic->int_value; + } + return result; +} + +inline char* +dynamic_to_string(Dynamic *dynamic, int *len){ + char *result = 0; + if (dynamic->type == dynamic_type_string){ + result = dynamic->str_value; + *len = dynamic->str_len; + } + return result; +} + +inline int +dynamic_to_bool(Dynamic *dynamic){ + int result = 0; + if (dynamic->type == dynamic_type_int){ + result = (dynamic->int_value != 0); + } + else{ + result = 1; + } + return result; +} + +typedef struct File_Info{ + String filename; + int folder; +} File_Info; + +typedef struct File_List{ + // Ignore this, it's for internal stuff. + void *block; + + // The list of files and folders. + File_Info *infos; + int count; + + // Ignore this, it's for internal stuff. + int block_size; +} File_List; + +#define MDFR_NONE 0x0 +#define MDFR_CTRL 0x1 +#define MDFR_ALT 0x2 +#define MDFR_SHIFT 0x4 + +enum Command_ID{ + cmdid_null, + cmdid_write_character, + cmdid_seek_left, + cmdid_seek_right, + cmdid_seek_whitespace_up, + cmdid_seek_whitespace_down, + cmdid_word_complete, + cmdid_set_mark, + cmdid_copy, + cmdid_cut, + cmdid_paste, + cmdid_paste_next, + cmdid_delete_range, + cmdid_timeline_scrub, + cmdid_undo, + cmdid_redo, + cmdid_history_backward, + cmdid_history_forward, + cmdid_interactive_new, + cmdid_interactive_open, + cmdid_reopen, + cmdid_save, + cmdid_interactive_save_as, + cmdid_change_active_panel, + cmdid_interactive_switch_buffer, + cmdid_interactive_kill_buffer, + cmdid_kill_buffer, + cmdid_toggle_line_wrap, + cmdid_toggle_endline_mode, + cmdid_to_uppercase, + cmdid_to_lowercase, + cmdid_toggle_show_whitespace, + cmdid_clean_all_lines, + cmdid_eol_dosify, + cmdid_eol_nixify, + cmdid_auto_tab_range, + cmdid_open_panel_vsplit, + cmdid_open_panel_hsplit, + cmdid_close_panel, + cmdid_move_left, + cmdid_move_right, + cmdid_delete, + cmdid_backspace, + cmdid_move_up, + cmdid_move_down, + cmdid_seek_end_of_line, + cmdid_seek_beginning_of_line, + cmdid_page_up, + cmdid_page_down, + cmdid_open_color_tweaker, + cmdid_cursor_mark_swap, + cmdid_open_menu, + cmdid_set_settings, + cmdid_command_line, + // + cmdid_count +}; + +enum Param_ID{ + par_range_start, + par_range_end, + par_name, + par_buffer_id, + par_do_in_background, + par_flags, + par_lex_as_cpp_file, + par_wrap_lines, + par_key_mapid, + par_cli_path, + par_cli_command, + par_clear_blank_lines, + // never below this + par_type_count +}; + +#define CLI_OverlapWithConflict 0x1 +#define CLI_AlwaysBindToView 0x2 + +// These are regular hooks, any of them can be set to any function +// that matches the HOOK_SIG pattern. +enum Hook_ID{ + hook_start, + hook_open_file, + hook_frame, + // never below this + hook_type_count +}; + +// These are for special hooks, each must bind to specialized signatures +// that do not necessarily have access to the app pointer. +enum Special_Hook_ID{ + _hook_scroll_rule = hook_type_count, +}; + +// NOTE(allen): None of the members of *_Summary structs nor any of the +// data pointed to by the members should be modified, I would have made +// them all const... but that causes a lot problems for C++ reasons. +struct Buffer_Summary{ + int exists; + int ready; + int buffer_id; + + int size; + + int file_name_len; + int buffer_name_len; + char *file_name; + char *buffer_name; + + int buffer_cursor_pos; + int is_lexed; + int map_id; +}; + +struct View_Summary{ + int exists; + int view_id; + int buffer_id; + int locked_buffer_id; + int hidden_buffer_id; + + Full_Cursor cursor; + Full_Cursor mark; + float preferred_x; + int line_height; + int unwrapped_lines; +}; + +#define UserInputKey 0 +#define UserInputMouse 1 + +struct User_Input{ + int type; + int abort; + union{ + Key_Event_Data key; + Mouse_State mouse; + }; + unsigned long long command; +}; + +#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2)) + +struct Query_Bar{ + String prompt; + String string; +}; + +struct Theme_Color{ + Style_Tag tag; + unsigned int color; +}; + + + +#define GET_BINDING_DATA(name) int name(void *data, int size) +#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app) +#define HOOK_SIG(name) int name(struct Application_Links *app) +#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target) + +extern "C"{ + typedef CUSTOM_COMMAND_SIG(Custom_Command_Function); + typedef GET_BINDING_DATA(Get_Binding_Data_Function); + typedef HOOK_SIG(Hook_Function); + typedef SCROLL_RULE_SIG(Scroll_Rule_Function); +} + +struct Application_Links; + +// Command exectuion +#define PUSH_PARAMETER_SIG(n) void n(Application_Links *app, Dynamic param, Dynamic value) +#define PUSH_MEMORY_SIG(n) char* n(Application_Links *app, int len) +#define EXECUTE_COMMAND_SIG(n) void n(Application_Links *app, int command_id) +#define CLEAR_PARAMETERS_SIG(n) void n(Application_Links *app) + +// File system navigation +#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity) +#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len) +#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) +#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len) +#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list) + +// Direct buffer manipulation +#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app) +#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer) + +#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int index) +#define GET_ACTIVE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app) +#define GET_PARAMETER_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int param_index) +#define GET_BUFFER_BY_NAME(n) Buffer_Summary n(Application_Links *app, char *filename, int len) + +#define BUFFER_SEEK_DELIMITER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out) +#define BUFFER_SEEK_STRING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out) + +#define REFRESH_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer) +#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out) +#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len) +#define BUFFER_SET_POS_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int pos) + +// File view manipulation +#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app) +#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view) + +#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int index) +#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app) + +#define REFRESH_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view) +#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) +#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek) +#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on) +#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id) + +// Directly get user input +#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type) + +// Queries +#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags) +#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags) + +// Color settings +#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len) +#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len) +#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) + + +// Boundry type flags +#define BoundryWhitespace 0x1 +#define BoundryToken 0x2 +#define BoundryAlphanumeric 0x4 +#define BoundryCamelCase 0x8 + + + +// Input type flags +#define EventOnAnyKey 0x1 +#define EventOnEsc 0x2 +#define EventOnLeftButton 0x4 +#define EventOnRightButton 0x8 +#define EventOnWheel 0x10 +#define EventOnButton (EventOnLeftButton | EventOnRightButton | EventOnWheel) + +// NOTE(allen): These don't work so much, so let's pretend they're not here for now. +#define EventOnMouseMove 0x20 +#define EventOnMouse (EventOnButton | EventOnMouseMove) + + + +extern "C"{ + // Command exectuion + typedef EXECUTE_COMMAND_SIG(Exec_Command_Function); + typedef PUSH_PARAMETER_SIG(Push_Parameter_Function); + typedef PUSH_MEMORY_SIG(Push_Memory_Function); + typedef CLEAR_PARAMETERS_SIG(Clear_Parameters_Function); + + // File system navigation + typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function); + typedef FILE_EXISTS_SIG(File_Exists_Function); + typedef DIRECTORY_CD_SIG(Directory_CD_Function); + typedef GET_FILE_LIST_SIG(Get_File_List_Function); + typedef FREE_FILE_LIST_SIG(Free_File_List_Function); + + // Buffer manipulation + typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function); + typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function); + + typedef GET_BUFFER_SIG(Get_Buffer_Function); + typedef GET_ACTIVE_BUFFER_SIG(Get_Active_Buffer_Function); + typedef GET_PARAMETER_BUFFER_SIG(Get_Parameter_Buffer_Function); + typedef GET_BUFFER_BY_NAME(Get_Buffer_By_Name_Function); + + typedef BUFFER_SEEK_DELIMITER_SIG(Buffer_Seek_Delimiter_Function); + typedef BUFFER_SEEK_STRING_SIG(Buffer_Seek_String_Function); + + typedef REFRESH_BUFFER_SIG(Refresh_Buffer_Function); + typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function); + typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function); + typedef BUFFER_SET_POS_SIG(Buffer_Set_Pos_Function); + + // View manipulation + typedef GET_VIEW_FIRST_SIG(Get_View_First_Function); + typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function); + + typedef GET_VIEW_SIG(Get_View_Function); + typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function); + + typedef REFRESH_VIEW_SIG(Refresh_View_Function); + typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function); + typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function); + typedef VIEW_SET_HIGHLIGHT_SIG(View_Set_Highlight_Function); + typedef VIEW_SET_BUFFER_SIG(View_Set_Buffer_Function); + + // Directly get user input + typedef GET_USER_INPUT_SIG(Get_User_Input_Function); + + // Queries + typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function); + typedef END_QUERY_BAR_SIG(End_Query_Bar_Function); + + // Color settings + typedef CHANGE_THEME_SIG(Change_Theme_Function); + typedef CHANGE_FONT_SIG(Change_Font_Function); + typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function); +} + +struct Application_Links{ + // User data + void *memory; + int memory_size; + + // Command exectuion + Exec_Command_Function *exec_command_keep_stack; + Push_Parameter_Function *push_parameter; + Push_Memory_Function *push_memory; + Clear_Parameters_Function *clear_parameters; + + // File system navigation + Directory_Get_Hot_Function *directory_get_hot; + File_Exists_Function *file_exists; + Directory_CD_Function *directory_cd; + Get_File_List_Function *get_file_list; + Free_File_List_Function *free_file_list; + + // Buffer manipulation + Get_Buffer_First_Function *get_buffer_first; + Get_Buffer_Next_Function *get_buffer_next; + + Get_Buffer_Function *get_buffer; + Get_Active_Buffer_Function *get_active_buffer; + Get_Parameter_Buffer_Function *get_parameter_buffer; + Get_Buffer_By_Name_Function *get_buffer_by_name; + + Buffer_Seek_Delimiter_Function *buffer_seek_delimiter; + Buffer_Seek_String_Function *buffer_seek_string; + + Refresh_Buffer_Function *refresh_buffer; + Buffer_Read_Range_Function *buffer_read_range; + Buffer_Replace_Range_Function *buffer_replace_range; + Buffer_Set_Pos_Function *buffer_set_pos; + + // View manipulation + Get_View_First_Function *get_view_first; + Get_View_Next_Function *get_view_next; + + Get_View_Function *get_view; + Get_Active_View_Function *get_active_view; + + Refresh_View_Function *refresh_view; + View_Set_Cursor_Function *view_set_cursor; + View_Set_Mark_Function *view_set_mark; + View_Set_Highlight_Function *view_set_highlight; + View_Set_Buffer_Function *view_set_buffer; + + // Directly get user input + Get_User_Input_Function *get_user_input; + + // Queries + Start_Query_Bar_Function *start_query_bar; + End_Query_Bar_Function *end_query_bar; + + // Theme + Change_Theme_Function *change_theme; + Change_Font_Function *change_font; + Set_Theme_Colors_Function *set_theme_colors; + + // Internal + void *cmd_context; +}; + +#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch) +typedef _GET_VERSION_SIG(_Get_Version_Function); + +extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){ + int result = (maj == MAJOR && min == MINOR && patch == PATCH); + return(result); +} + +struct Custom_API{ + Get_Binding_Data_Function *get_bindings; + _Get_Version_Function *get_alpha_4coder_version; +}; + +// NOTE(allen): definitions for the buffer that communicates to 4ed.exe + +enum Binding_Unit_Type{ + unit_header, + unit_map_begin, + unit_binding, + unit_callback, + unit_inherit, + unit_hook +}; + +enum Map_ID{ + mapid_global = (1 << 24), + mapid_file, + + // NOTE(allen): mapid_nomap will remain empty even if you attempt to fill it + // it is for setting a map's parent to nothing, in cases where you don't want + // to inherit from global (which is the default). + mapid_nomap +}; + +struct Binding_Unit{ + Binding_Unit_Type type; + union{ + struct{ int total_size; int user_map_count; int error; } header; + + struct{ int mapid; int bind_count; } map_begin; + struct{ int mapid; } map_inherit; + struct{ + short code; + unsigned char modifiers; + int command_id; + } binding; + struct{ + short code; + unsigned char modifiers; + Custom_Command_Function *func; + } callback; + struct{ + int hook_id; + void *func; + } hook; + }; +}; diff --git a/test_data/lots_of_files/4coder_helper.h b/test_data/lots_of_files/4coder_helper.h new file mode 100644 index 0000000..97494c2 --- /dev/null +++ b/test_data/lots_of_files/4coder_helper.h @@ -0,0 +1,343 @@ +/* + * Bind helper struct and functions + */ + +struct Bind_Helper{ + Binding_Unit *cursor, *start, *end; + Binding_Unit *header, *group; + int write_total; + int error; +}; + +#define BH_ERR_NONE 0 +#define BH_ERR_MISSING_END 1 +#define BH_ERR_MISSING_BEGIN 2 +#define BH_ERR_OUT_OF_MEMORY 3 + +inline void +copy(char *dest, const char *src, int len){ + for (int i = 0; i < len; ++i){ + *dest++ = *src++; + } +} + +inline Binding_Unit* +write_unit(Bind_Helper *helper, Binding_Unit unit){ + Binding_Unit *p = 0; + helper->write_total += sizeof(*p); + if (helper->error == 0 && helper->cursor != helper->end){ + p = helper->cursor++; + *p = unit; + } + return p; +} + +inline char* +write_inline_string(Bind_Helper *helper, char *value, int len){ + char *dest = 0; + helper->write_total += len; + if (helper->error == 0){ + dest = (char*)helper->cursor; + int cursor_advance = len + sizeof(*helper->cursor) - 1; + cursor_advance /= sizeof(*helper->cursor); + cursor_advance *= sizeof(*helper->cursor); + helper->cursor += cursor_advance; + if (helper->cursor < helper->end){ + copy(dest, value, len); + } + else{ + helper->error = BH_ERR_OUT_OF_MEMORY; + } + } + return dest; +} + +inline Bind_Helper +begin_bind_helper(void *data, int size){ + Bind_Helper result; + + result.header = 0; + result.group = 0; + result.write_total = 0; + result.error = 0; + + result.cursor = (Binding_Unit*)data; + result.start = result.cursor; + result.end = result.start + size / sizeof(*result.cursor); + + Binding_Unit unit; + unit.type = unit_header; + unit.header.total_size = sizeof(*result.header); + result.header = write_unit(&result, unit); + result.header->header.user_map_count = 0; + + return result; +} + +inline void +begin_map(Bind_Helper *helper, int mapid){ + if (helper->group != 0 && helper->error == 0) helper->error = BH_ERR_MISSING_END; + if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count; + + Binding_Unit unit; + unit.type = unit_map_begin; + unit.map_begin.mapid = mapid; + helper->group = write_unit(helper, unit); + helper->group->map_begin.bind_count = 0; +} + +inline void +end_map(Bind_Helper *helper){ + if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; + helper->group = 0; +} + +inline void +bind(Bind_Helper *helper, short code, unsigned char modifiers, int cmdid){ + if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; + if (!helper->error) ++helper->group->map_begin.bind_count; + + Binding_Unit unit; + unit.type = unit_binding; + unit.binding.command_id = cmdid; + unit.binding.code = code; + unit.binding.modifiers = modifiers; + + write_unit(helper, unit); +} + +inline void +bind(Bind_Helper *helper, short code, unsigned char modifiers, Custom_Command_Function *func){ + if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; + if (!helper->error) ++helper->group->map_begin.bind_count; + + Binding_Unit unit; + unit.type = unit_callback; + unit.callback.func = func; + unit.callback.code = code; + unit.callback.modifiers = modifiers; + + write_unit(helper, unit); +} + +inline void +bind_vanilla_keys(Bind_Helper *helper, int cmdid){ + bind(helper, 0, 0, cmdid); +} + +inline void +bind_vanilla_keys(Bind_Helper *helper, Custom_Command_Function *func){ + bind(helper, 0, 0, func); +} + +inline void +bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int cmdid){ + bind(helper, 0, modifiers, cmdid); +} + +inline void +bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, Custom_Command_Function *func){ + bind(helper, 0, modifiers, func); +} + +inline void +inherit_map(Bind_Helper *helper, int mapid){ + if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; + if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count; + + Binding_Unit unit; + unit.type = unit_inherit; + unit.map_inherit.mapid = mapid; + + write_unit(helper, unit); +} + +inline void +set_hook(Bind_Helper *helper, int hook_id, Hook_Function *func){ + Binding_Unit unit; + unit.type = unit_hook; + unit.hook.hook_id = hook_id; + unit.hook.func = (void*) func; + + write_unit(helper, unit); +} + +inline void +set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){ + Binding_Unit unit; + unit.type = unit_hook; + unit.hook.hook_id = _hook_scroll_rule; + unit.hook.func = (void*) func; + + write_unit(helper, unit); +} + +inline void +end_bind_helper(Bind_Helper *helper){ + if (helper->header){ + helper->header->header.total_size = (int)(helper->cursor - helper->start); + helper->header->header.error = helper->error; + } +} + +// NOTE(allen): Useful functions and overloads on app links +inline void +push_parameter(Application_Links *app, int param, int value){ + app->push_parameter(app, dynamic_int(param), dynamic_int(value)); +} + +inline void +push_parameter(Application_Links *app, int param, const char *value, int value_len){ + char *value_copy = app->push_memory(app, value_len+1); + copy(value_copy, value, value_len); + value_copy[value_len] = 0; + app->push_parameter(app, dynamic_int(param), dynamic_string(value_copy, value_len)); +} + +inline void +push_parameter(Application_Links *app, const char *param, int param_len, int value){ + char *param_copy = app->push_memory(app, param_len+1); + copy(param_copy, param, param_len); + param_copy[param_len] = 0; + app->push_parameter(app, dynamic_string(param_copy, param_len), dynamic_int(value)); +} + +inline void +push_parameter(Application_Links *app, const char *param, int param_len, const char *value, int value_len){ + char *param_copy = app->push_memory(app, param_len+1); + char *value_copy = app->push_memory(app, value_len+1); + copy(param_copy, param, param_len); + copy(value_copy, value, value_len); + value_copy[value_len] = 0; + param_copy[param_len] = 0; + + app->push_parameter(app, dynamic_string(param_copy, param_len), dynamic_string(value_copy, value_len)); +} + +inline Range +get_range(View_Summary *view){ + Range range; + range = make_range(view->cursor.pos, view->mark.pos); + return(range); +} + +inline void +exec_command(Application_Links *app, Command_ID id){ + app->exec_command_keep_stack(app, id); + app->clear_parameters(app); +} + +inline void +exec_command(Application_Links *app, Custom_Command_Function *func){ + func(app); + app->clear_parameters(app); +} + +inline void +active_view_to_line(Application_Links *app, int line_number){ + View_Summary view; + view = app->get_active_view(app); + + // NOTE(allen|a3.4.4): We don't have to worry about whether this is a valid line number. + // When it's not possible to place a cursor at the position for whatever reason it will set the + // cursor to a nearby valid position. + app->view_set_cursor(app, &view, seek_line_char(line_number, 0), 1); +} + +inline View_Summary +get_first_view_with_buffer(Application_Links *app, int buffer_id){ + View_Summary result = {}; + View_Summary test = {}; + + for(test = app->get_view_first(app); + test.exists; + app->get_view_next(app, &test)){ + if(test.locked_buffer_id == buffer_id){ + result = test; + break; + } + } + + return(result); +} + +inline int +key_is_unmodified(Key_Event_Data *key){ + char *mods = key->modifiers; + int unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX]; + return(unmodified); +} + +static int +query_user_general(Application_Links *app, Query_Bar *bar, int force_number){ + User_Input in; + int success = 1; + int good_character = 0; + + // NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to. + // start a query bar, but it will be unusual behavior from the point of view of the + // user, if this command starts intercepting input even though no prompt is shown. + // This will only happen if you have a lot of bars open already or if the current view + // doesn't support query bars. + if (app->start_query_bar(app, bar, 0) == 0) return 0; + + while (1){ + // NOTE(allen|a3.4.4): This call will block until the user does one of the input + // types specified in the flags. The first set of flags are inputs you'd like to intercept + // that you don't want to abort on. The second set are inputs that you'd like to cause + // the command to abort. If an event satisfies both flags, it is treated as an abort. + in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton); + + // NOTE(allen|a3.4.4): The responsible thing to do on abort is to end the command + // without waiting on get_user_input again. + if (in.abort){ + success = 0; + break; + } + + good_character = 0; + if (key_is_unmodified(&in.key)){ + if (force_number){ + if (in.key.character >= '0' && in.key.character <= '9'){ + good_character = 1; + } + } + else{ + if (in.key.character != 0){ + good_character = 1; + } + } + } + + // NOTE(allen|a3.4.4): All we have to do to update the query bar is edit our + // local Query_Bar struct! This is handy because it means our Query_Bar + // is always correct for typical use without extra work updating the bar. + if (in.type == UserInputKey){ + if (in.key.keycode == '\n' || in.key.keycode == '\t'){ + break; + } + else if (in.key.keycode == key_back){ + --bar->string.size; + } + else if (good_character){ + append(&bar->string, in.key.character); + } + } + } + + return(success); +} + +inline int +query_user_string(Application_Links *app, Query_Bar *bar){ + int success = query_user_general(app, bar, 0); + return(success); +} + +inline int +query_user_number(Application_Links *app, Query_Bar *bar){ + int success = query_user_general(app, bar, 1); + return(success); +} + +inline String empty_string() {String Result = {}; return(Result);} diff --git a/test_data/lots_of_files/4coder_keycodes.h b/test_data/lots_of_files/4coder_keycodes.h new file mode 100644 index 0000000..92df28f --- /dev/null +++ b/test_data/lots_of_files/4coder_keycodes.h @@ -0,0 +1,30 @@ +enum Key_Code{ + key_back = 1, + key_up = 2, + key_down = 3, + key_left = 4, + key_right = 5, + key_del = 6, + key_insert = 7, + key_home = 8, + key_end = 11, + key_page_up = 12, + key_page_down = 13, + key_esc = 14, + key_f1 = 127, + key_f2 = 128, + key_f3 = 129, + key_f4 = 130, + key_f5 = 131, + key_f6 = 132, + key_f7 = 133, + key_f8 = 134, + key_f9 = 135, + key_f10 = 136, + key_f11 = 137, + key_f12 = 138, + key_f13 = 139, + key_f14 = 140, + key_f15 = 141, + key_f16 = 142, +}; diff --git a/test_data/lots_of_files/4coder_string.h b/test_data/lots_of_files/4coder_string.h new file mode 100644 index 0000000..f736dbe --- /dev/null +++ b/test_data/lots_of_files/4coder_string.h @@ -0,0 +1,1206 @@ +/* "4cpp" Open C++ Parser v0.1: String + no warranty implied; use at your own risk + +NOTES ON USE: + OPTIONS: + Set options by defining macros before including this file + + FCPP_STRING_IMPLEMENTATION - causes this file to output function implementations + - this option is unset after use so that future includes of this file + in the same unit do not continue to output implementations + + FCPP_LINK - defines linkage of non-inline functions, defaults to static + FCPP_EXTERN changes FCPP_LINK default to extern, this option is ignored if FCPP_LINK is defined + + include the file "4cpp_clear_config.h" if yo want to undefine all options for some reason + + HIDDEN DEPENDENCIES: + none + */ + +// TOP +// TODO(allen): +// - comments +// - memcpy / memmove replacements (different file for optimization options?) +// - examples and docs +// - finish a full set of tools for file name handling +// + +#include "4coder_config.h" + +#ifndef FCPP_STRING_INC +#define FCPP_STRING_INC + +#ifndef FRED_STRING_STRUCT +#define FRED_STRING_STRUCT +struct String{ + char *str; + int size; + int memory_size; +}; + +struct Offset_String{ + int offset; + int size; +}; +#endif + +inline bool char_not_slash(char c) { return (c != '\\' && c != '/'); } +inline bool char_is_slash(char c) { return (c == '\\' || c == '/'); } + +inline char char_to_upper(char c) { return (c >= 'a' && c <= 'z') ? c + (char)('A' - 'a') : c; } +inline char char_to_lower(char c) { return (c >= 'A' && c <= 'Z') ? c - (char)('A' - 'a') : c; } + +inline bool char_is_whitespace(char c) { return (c == ' ' || c == '\n' || c == '\r' || c == '\t'); } +inline bool char_is_white_not_r(char c) { return (c == ' ' || c == '\n' || c == '\t'); } +inline bool char_is_lower(char c) { return (c >= 'a' && c <= 'z'); } +inline bool char_is_upper(char c) { return (c >= 'A' && c <= 'Z'); } +inline bool char_is_alpha(char c) { return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); } +inline bool char_is_alpha_true(char c) { return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); } +inline bool char_is_numeric(char c) { return (c >= '0' && c <= '9'); } +inline bool char_is_alpha_numeric_true(char c) { return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); } +inline bool char_is_alpha_numeric(char c) { return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); } +inline bool char_is_hex(char c) { return c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'; } +inline bool char_is_basic(char c) { return c >= ' ' && c <= '~'; } + +inline String make_string(void *s, int size, int mem_size); +inline String make_string(void *s, int size); + +#define make_lit_string(str) (make_string((char*)(str), sizeof(str)-1, sizeof(str))) +#define make_fixed_width_string(str) (make_string((char*)(str), 0, sizeof(str))) + +#define expand_str(s) ((s).str), ((s).size) + +inline String make_string_slowly(void *s); +inline char* make_c_str(String s); + +inline String substr(String str, int start); +inline String substr(String str, int start, int size); +inline String substr_slowly(char *s, int start); +inline String substr(char *s, int start, int size); +inline String tailstr(String s); + + +FCPP_LINK int str_size(char *s); + +FCPP_LINK bool match(char *a, char *b); +FCPP_LINK bool match(String a, char *b); +inline bool match(char *a, String b) { return match(b,a); } +FCPP_LINK bool match(String a, String b); + +FCPP_LINK bool match_part(char *a, char *b, int *len); +FCPP_LINK bool match_part(String a, char *b, int *len); +inline bool match_part(char *a, char *b) { int x; return match_part(a,b,&x); } +inline bool match_part(String a, char *b) { int x; return match_part(a,b,&x); } +FCPP_LINK bool match_part(char *a, String b); +FCPP_LINK bool match_part(String a, String b); + +FCPP_LINK bool match_unsensitive(char *a, char *b); +FCPP_LINK bool match_unsensitive(String a, char *b); +inline bool match_unsensitive(char *a, String b) { return match_unsensitive(b,a); } +FCPP_LINK bool match_unsensitive(String a, String b); + +FCPP_LINK bool match_part_unsensitive(char *a, char *b, int *len); +FCPP_LINK bool match_part_unsensitive(String a, char *b, int *len); +inline bool match_part_unsensitive(char *a, char *b) { int x; return match_part(a,b,&x); } +inline bool match_part_unsensitive(String a, char *b) { int x; return match_part(a,b,&x); } +FCPP_LINK bool match_part_unsensitive(char *a, String b); +FCPP_LINK bool match_part_unsensitive(String a, String b); + +FCPP_LINK int find(char *s, int start, char c); +FCPP_LINK int find(String s, int start, char c); +FCPP_LINK int find(char *s, int start, char *c); +FCPP_LINK int find(String s, int start, char *c); + +FCPP_LINK int find_substr(char *s, int start, String seek); +FCPP_LINK int find_substr(String s, int start, String seek); +FCPP_LINK int rfind_substr(String s, int start, String seek); + +FCPP_LINK int find_substr_unsensitive(char *s, int start, String seek); +FCPP_LINK int find_substr_unsensitive(String s, int start, String seek); + +inline bool has_substr(char *s, String seek) { return (s[find_substr(s, 0, seek)] != 0); } +inline bool has_substr(String s, String seek) { return (find_substr(s, 0, seek) < s.size); } + +inline bool has_substr_unsensitive(char *s, String seek) { return (s[find_substr_unsensitive(s, 0, seek)] != 0); } +inline bool has_substr_unsensitive(String s, String seek) { return (find_substr_unsensitive(s, 0, seek) < s.size); } + +FCPP_LINK int int_to_str_size(int x); +FCPP_LINK int int_to_str(int x, char *s_out); +FCPP_LINK bool int_to_str(int x, String *s_out); +FCPP_LINK bool append_int_to_str(int x, String *s_out); + +FCPP_LINK int str_to_int(char *s); +FCPP_LINK int str_to_int(String s); +FCPP_LINK int hexchar_to_int(char c); +FCPP_LINK char int_to_hexchar(int c); +FCPP_LINK int hexstr_to_int(String s); + +FCPP_LINK int copy_fast_unsafe(char *dest, char *src); +FCPP_LINK void copy_fast_unsafe(char *dest, String src); +FCPP_LINK bool copy_checked(String *dest, String src); +FCPP_LINK bool copy_partial(String *dest, char *src); +FCPP_LINK bool copy_partial(String *dest, String src); + +inline int copy(char *dest, char *src) { return copy_fast_unsafe(dest, src); } +inline void copy(String *dest, String src) { copy_checked(dest, src); } +inline void copy(String *dest, char *src) { copy_partial(dest, src); } + +FCPP_LINK bool append_checked(String *dest, String src); +FCPP_LINK bool append_partial(String *dest, char *src); +FCPP_LINK bool append_partial(String *dest, String src); + +FCPP_LINK bool append(String *dest, char c); +inline bool append(String *dest, String src) { return append_partial(dest, src); } +inline bool append(String *dest, char *src) { return append_partial(dest, src); } +inline bool terminate_with_null(String *str){ + bool result; + if (str->size < str->memory_size){ + str->str[str->size] = 0; + result = 1; + } + else{ + str->str[str->size-1] = 0; + result = 0; + } + return result; +} + +FCPP_LINK int compare(char *a, char *b); +FCPP_LINK int compare(String a, char *b); +inline int compare(char *a, String b) { return -compare(b,a); } +FCPP_LINK int compare(String a, String b); + +FCPP_LINK int reverse_seek_slash(String str); +FCPP_LINK int reverse_seek_slash(String str, int start_pos); +inline bool get_front_of_directory(String *dest, String dir) { return append_checked(dest, substr(dir, reverse_seek_slash(dir) + 1)); } +inline bool get_path_of_directory(String *dest, String dir) { return append_checked(dest, substr(dir, 0, reverse_seek_slash(dir) + 1)); } +FCPP_LINK bool set_last_folder(String *dir, char *folder_name, char slash); +FCPP_LINK bool set_last_folder(String *dir, String folder_name, char slash); +FCPP_LINK String file_extension(String str); +FCPP_LINK String file_extension_slowly(char *str); +FCPP_LINK char * file_extension_c(String str); +FCPP_LINK bool remove_last_folder(String *str); +FCPP_LINK void replace_char(String str, char replace, char with); + +inline String make_string(void *str, int size, int mem_size){ + String result; + result.str = (char*)str; + result.size = size; + result.memory_size = mem_size; + return result; +} + +inline String +make_string(void *str, int size){ + String result; + result.str = (char*)str; + result.size = size; + result.memory_size = size; + return result; +} + +inline String +make_string_slowly(void *str){ + String result; + result.str = (char*)str; + result.size = str_size((char*)str); + result.memory_size = result.size; + return result; +} + +inline char* +make_c_str(String str){ + if (str.size < str.memory_size){ + str.str[str.size] = 0; + } + else{ + str.str[str.memory_size-1] = 0; + } + return (char*)str.str; +} + +inline String +substr(String str, int start){ + String result; + result.str = str.str + start; + result.size = str.size - start; + return result; +} + +inline String +substr(String str, int start, int size){ + String result; + result.str = str.str + start; + if (start + size > str.size){ + result.size = str.size - start; + } + else{ + result.size = size; + } + return result; +} + +inline String +substr_slowly(char *str, int start){ + String result; + result.str = str + start; + result.size = str_size(result.str); + return result; +} + +inline String +substr(char *str, int start, int size){ + String result; + result.str = str + start; + result.size = size; + for (int i = 0; i < size; ++i){ + if (result.str[i] == 0){ + result.size = i; + break; + } + } + return result; +} + +inline String +tailstr(String str){ + String result; + result.str = str.str + str.size; + result.memory_size = str.memory_size - str.size; + result.size = 0; + return result; +} + +#endif // #ifndef FCPP_STRING_INC + +#ifdef FCPP_STRING_IMPLEMENTATION + +#ifndef FCPP_DID_STRING_IMPLEMENTATION +#define FCPP_DID_STRING_IMPLEMENTATION + +FCPP_LINK int +str_size(char *str){ + int i = 0; + while (str[i]) ++i; + return i; +} + +FCPP_LINK bool +match(char *a, char *b){ + for (int i = 0;; ++i){ + if (a[i] != b[i]){ + return 0; + } + if (a[i] == 0){ + return 1; + } + } +} + +FCPP_LINK bool +match(String a, char *b){ + int i = 0; + for (; i < a.size; ++i){ + if (a.str[i] != b[i]){ + return 0; + } + } + if (b[i] != 0){ + return 0; + } + return 1; +} + +FCPP_LINK bool +match(String a, String b){ + if (a.size != b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (a.str[i] != b.str[i]){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part(char *a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (a[i] != b[i]){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part(String a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (a.str[i] != b[i] || i == a.size){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part(char *a, String b){ + for (int i = 0; i != b.size; ++i){ + if (a[i] != b.str[i]){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part(String a, String b){ + if (a.size < b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (a.str[i] != b.str[i]){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_unsensitive(char *a, char *b){ + for (int i = 0;; ++i){ + if (char_to_upper(a[i]) != + char_to_upper(b[i])){ + return 0; + } + if (a[i] == 0){ + return 1; + } + } +} + +FCPP_LINK bool +match_unsensitive(String a, char *b){ + int i = 0; + for (; i < a.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b[i])){ + return 0; + } + } + if (b[i] != 0){ + return 0; + } + return 1; +} + +FCPP_LINK bool +match_unsensitive(String a, String b){ + if (a.size != b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(char *a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b[i])){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(String a, char *b, int *len){ + int i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b[i]) || + i == a.size){ + return 0; + } + } + *len = i; + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(char *a, String b){ + for (int i = 0; i != b.size; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + +FCPP_LINK bool +match_part_unsensitive(String a, String b){ + if (a.size < b.size){ + return 0; + } + for (int i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} + +FCPP_LINK int +find(char *str, int start, char character){ + int i = start; + while (str[i] != character && str[i] != 0) ++i; + return i; +} + +FCPP_LINK int +find(String str, int start, char character){ + int i = start; + while (i < str.size && str.str[i] != character) ++i; + return i; +} + +FCPP_LINK int +find(char *str, int start, char *characters){ + int i = start, j; + while (str[i] != 0){ + for (j = 0; characters[j]; ++j){ + if (str[i] == characters[j]){ + return i; + } + } + ++i; + } + return i; +} + +FCPP_LINK int +find(String str, int start, char *characters){ + int i = start, j; + while (i < str.size){ + for (j = 0; characters[j]; ++j){ + if (str.str[i] == characters[j]){ + return i; + } + } + ++i; + } + return i; +} + +FCPP_LINK int +find_substr(char *str, int start, String seek){ + int i, j, k; + bool hit; + + if (seek.size == 0){ + return str_size(str); + } + for (i = start; str[i]; ++i){ + if (str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return i; +} + +FCPP_LINK int +find_substr(String str, int start, String seek){ + int stop_at, i, j, k; + bool hit; + + if (seek.size == 0){ + return str.size; + } + stop_at = str.size - seek.size + 1; + for (i = start; i < stop_at; ++i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str.str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return str.size; +} + +FCPP_LINK int +rfind_substr(String str, int start, String seek){ + int i, j, k; + bool hit; + + if (seek.size == 0){ + return -1; + } + if (start + seek.size > str.size){ + start = str.size - seek.size; + } + for (i = start; i >= 0; --i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str.str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return -1; +} + +FCPP_LINK int +find_substr_unsensitive(char *str, int start, String seek){ + int i, j, k; + bool hit; + char a_upper, b_upper; + + if (seek.size == 0){ + return str_size(str); + } + for (i = start; str[i]; ++i){ + if (str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + a_upper = char_to_upper(str[k]); + b_upper = char_to_upper(seek.str[j]); + if (a_upper != b_upper){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return i; +} + +FCPP_LINK int +find_substr_unsensitive(String str, int start, String seek){ + int i, j, k; + int stop_at; + bool hit; + char a_upper, b_upper; + + if (seek.size == 0){ + return str.size; + } + stop_at = str.size - seek.size + 1; + for (i = start; i < stop_at; ++i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + a_upper = char_to_upper(str.str[k]); + b_upper = char_to_upper(seek.str[j]); + if (a_upper != b_upper){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return str.size; +} + +FCPP_LINK int +int_to_str_size(int x){ + int size; + if (x < 0){ + size = 0; + } + else{ + size = 1; + x /= 10; + while (x != 0){ + x /= 10; + ++size; + } + } + return size; +} + +FCPP_LINK int +int_to_str(int x, char *str){ + int size, i, j; + bool negative; + char temp; + + size = 0; + if (x == 0){ + str[0] = '0'; + str[1] = 0; + size = 1; + } + else{ + size = 0; + negative = 0; + if (x < 0){ + negative = 1; + x = -x; + str[size++] = '-'; + } + while (x != 0){ + i = x % 10; + x /= 10; + str[size++] = (char)('0' + i); + } + // NOTE(allen): Start i = 0 if not negative, start i = 1 if is negative + // because - should not be flipped if it is negative :) + for (i = negative, j = size-1; i < j; ++i, --j){ + temp = str[i]; + str[i] = str[j]; + str[j] = temp; + } + str[size] = 0; + } + return size; +} + +FCPP_LINK bool +int_to_str(int x, String *dest){ + bool result = 1; + char *str = dest->str; + int memory_size = dest->memory_size; + int size, i, j; + bool negative; + + if (x == 0){ + str[0] = '0'; + dest->size = 1; + } + else{ + size = 0; + negative = 0; + if (x < 0){ + negative = 1; + x = -x; + str[size++] = '-'; + } + while (x != 0){ + if (size == memory_size){ + result = 0; + break; + } + i = x % 10; + x /= 10; + str[size++] = (char)('0' + i); + } + if (result){ + // NOTE(allen): Start i = 0 if not negative, start i = 1 if is negative + // because - should not be flipped if it is negative :) + for (i = negative, j = size-1; i < j; ++i, --j){ + char temp = str[i]; + str[i] = str[j]; + str[j] = temp; + } + dest->size = size; + } + else{ + dest->size = 0; + } + } + return result; +} + +FCPP_LINK bool +append_int_to_str(int x, String *dest){ + String last_part = tailstr(*dest); + bool result = int_to_str(x, &last_part); + if (result){ + dest->size += last_part.size; + } + return result; +} + +FCPP_LINK int +str_to_int(char *str){ + int x = 0; + for (; *str; ++str){ + if (*str >= '0' || *str <= '9'){ + x *= 10; + x += *str - '0'; + } + else{ + x = 0; + break; + } + } + return(x); +} + +FCPP_LINK int +str_to_int(String str){ + int x, i; + if (str.size == 0){ + x = 0; + } + else{ + x = str.str[0] - '0'; + for (i = 1; i < str.size; ++i){ + x *= 10; + x += str.str[i] - '0'; + } + } + return x; +} + +FCPP_LINK int +hexchar_to_int(char c){ + int x; + if (c >= '0' && c <= '9'){ + x = c-'0'; + } + else if (c > 'F'){ + x = c+(10-'a'); + } + else{ + x = c+(10-'A'); + } + return x; +} + +FCPP_LINK char +int_to_hexchar(int x){ + return (x<10)?((char)x+'0'):((char)x+'a'-10); +} + +FCPP_LINK int +hexstr_to_int(String str){ + int x, i; + if (str.size == 0){ + x = 0; + } + else{ + x = hexchar_to_int(str.str[0]); + for (i = 1; i < str.size; ++i){ + x *= 0x10; + x += hexchar_to_int(str.str[i]); + } + } + return x; +} + +FCPP_LINK int +copy_fast_unsafe(char *dest, char *src){ + char *start = dest; + while (*src != 0){ + *dest = *src; + ++dest; + ++src; + } + return (int)(dest - start); +} + +FCPP_LINK void +copy_fast_unsafe(char *dest, String src){ + int i = 0; + while (i != src.size){ + dest[i] = src.str[i]; + ++i; + } +} + +FCPP_LINK bool +copy_checked(String *dest, String src){ + char *dest_str; + int i; + if (dest->memory_size < src.size){ + return 0; + } + dest_str = dest->str; + for (i = 0; i < src.size; ++i){ + dest_str[i] = src.str[i]; + } + dest->size = src.size; + return 1; +} + +FCPP_LINK bool +copy_partial(String *dest, char *src){ + int i = 0; + int memory_size = dest->memory_size; + char *dest_str = dest->str; + while (src[i] != 0){ + if (i >= memory_size){ + return 0; + } + dest_str[i] = src[i]; + ++i; + } + dest->size = i; + return 1; +} + +FCPP_LINK bool +copy_partial(String *dest, String src){ + bool result; + int memory_size = dest->memory_size; + char *dest_str = dest->str; + if (memory_size < src.size){ + result = 0; + for (int i = 0; i < memory_size; ++i){ + dest_str[i] = src.str[i]; + } + dest->size = memory_size; + } + else{ + result = 1; + for (int i = 0; i < src.size; ++i){ + dest_str[i] = src.str[i]; + } + dest->size = src.size; + } + return result; +} + +FCPP_LINK bool +append_checked(String *dest, String src){ + String end; + end = tailstr(*dest); + bool result = copy_checked(&end, src); + // NOTE(allen): This depends on end.size still being 0 if + // the check failed and no coppy occurred. + dest->size += end.size; + return result; +} + +FCPP_LINK bool +append_partial(String *dest, char *src){ + String end = tailstr(*dest); + bool result = copy_partial(&end, src); + dest->size += end.size; + return result; +} + +FCPP_LINK bool +append_partial(String *dest, String src){ + String end = tailstr(*dest); + bool result = copy_partial(&end, src); + dest->size += end.size; + return result; +} + +FCPP_LINK bool +append(String *dest, char c){ + bool result = 0; + if (dest->size < dest->memory_size){ + dest->str[dest->size++] = c; + result = 1; + } + return result; +} + +FCPP_LINK int +compare(char *a, char *b){ + int i = 0; + while (a[i] == b[i] && a[i] != 0){ + ++i; + } + return (a[i] > b[i]) - (a[i] < b[i]); +} + +FCPP_LINK int +compare(String a, char *b){ + int i = 0; + while (i < a.size && a.str[i] == b[i]){ + ++i; + } + if (i < a.size){ + return (a.str[i] > b[i]) - (a.str[i] < b[i]); + } + else{ + if (b[i] == 0){ + return 0; + } + else{ + return -1; + } + } +} + +FCPP_LINK int +compare(String a, String b){ + int i = 0; + while (i < a.size && i < b.size && a.str[i] == b.str[i]){ + ++i; + } + if (i < a.size && i < b.size){ + return (a.str[i] > b.str[i]) - (a.str[i] < b.str[i]); + } + else{ + return (a.size > b.size) - (a.size < b.size); + } +} + +FCPP_LINK int +reverse_seek_slash(String str, int pos){ + int i = str.size - 1 - pos; + while (i >= 0 && char_not_slash(str.str[i])){ + --i; + } + return i; +} + +FCPP_LINK int +reverse_seek_slash(String str){ + return(reverse_seek_slash(str, 0)); +} + +FCPP_LINK bool +set_last_folder(String *dir, char *folder_name, char slash){ + char str[2]; + bool result = 0; + int size = reverse_seek_slash(*dir) + 1; + dir->size = size; + str[0] = slash; + str[1] = 0; + if (append(dir, folder_name)){ + if (append(dir, str)){ + result = 1; + } + } + if (!result){ + dir->size = size; + } + return result; +} + +FCPP_LINK bool +set_last_folder(String *dir, String folder_name, char slash){ + char str[2]; + bool result = 0; + int size = reverse_seek_slash(*dir) + 1; + dir->size = size; + str[0] = slash; + str[1] = 0; + if (append(dir, folder_name)){ + if (append(dir, str)){ + result = 1; + } + } + if (!result){ + dir->size = size; + } + return result; +} + +FCPP_LINK String +file_extension(String str){ + int i; + for (i = str.size - 1; i >= 0; --i){ + if (str.str[i] == '.') break; + } + ++i; + return make_string(str.str+i, str.size-i); +} + +FCPP_LINK String +file_extension_slowly(char *str){ + int s, i; + for (s = 0; str[s]; ++s); + for (i = s - 1; i >= 0; --i){ + if (str[i] == '.') break; + } + ++i; + return make_string(str+i, s-i); +} + +FCPP_LINK char* +file_extension_c(String str){ + int i; + for (i = str.size - 1; i >= 0; --i){ + if (str.str[i] == '.') break; + } + ++i; + return str.str+i; +} + +FCPP_LINK bool +remove_last_folder(String *str){ + bool result = 0; + int end = reverse_seek_slash(*str, 1); + if (end >= 0){ + result = 1; + str->size = end + 1; + } + return(result); +} + +FCPP_LINK void +replace_char(String str, char replace, char with){ + char *s = str.str; + int i; + + for (i = 0; i < str.size; ++i, ++s){ + if (*s == replace) *s = with; + } +} + +// NOTE(allen): experimental section, things below here are +// not promoted to public API level yet. + +#ifndef ArrayCount +#define ArrayCount(a) ((sizeof(a))/sizeof(*a)) +#endif + +struct Absolutes{ + String a[8]; + int count; +}; + +FCPP_LINK void +get_absolutes(String name, Absolutes *absolutes, bool implicit_first, bool implicit_last){ + int count = 0; + int max = ArrayCount(absolutes->a) - 1; + if (implicit_last) --max; + + String str; + str.str = name.str; + str.size = 0; + str.memory_size = 0; + bool prev_was_wild = 0; + + if (implicit_first){ + absolutes->a[count++] = str; + prev_was_wild = 1; + } + + int i; + for (i = 0; i < name.size; ++i){ + if (name.str[i] == '*' && count < max){ + if (!prev_was_wild){ + str.memory_size = str.size; + absolutes->a[count++] = str; + str.size = 0; + } + str.str = name.str + i + 1; + prev_was_wild = 1; + } + else{ + ++str.size; + prev_was_wild = 0; + } + } + + str.memory_size = str.size; + absolutes->a[count++] = str; + + if (implicit_last){ + str.size = 0; + str.memory_size = 0; + absolutes->a[count++] = str; + } + + absolutes->count = count; +} + +FCPP_LINK bool +wildcard_match(Absolutes *absolutes, char *x, int case_sensitive){ + bool r = 1; + String *a = absolutes->a; + + bool (*match_func)(char*, String); + bool (*match_part_func)(char*, String); + + if (case_sensitive){ + match_func = match; + match_part_func = match_part; + } + else{ + match_func = match_unsensitive; + match_part_func = match_part_unsensitive; + } + + if (absolutes->count == 1){ + r = match_func(x, *a); + } + else{ + if (!match_part_func(x, *a)){ + r = 0; + } + else{ + String *max = a + absolutes->count - 1; + x += a->size; + ++a; + while (a < max){ + if (*x == 0){ + r = 0; + break; + } + if (match_part_func(x, *a)){ + x += a->size; + ++a; + } + else{ + ++x; + } + } + if (r && a->size > 0){ + r = 0; + while (*x != 0){ + if (match_part_func(x, *a) && *(x + a->size) == 0){ + r = 1; + break; + } + else{ + ++x; + } + } + } + } + } + return r; +} + +FCPP_LINK bool +wildcard_match(Absolutes *absolutes, String x, int case_sensitive){ + terminate_with_null(&x); + return wildcard_match(absolutes, x.str, case_sensitive); +} + +#endif // #ifndef FCPP_DID_STRING_IMPLEMENTATION + +#undef FCPP_STRING_IMPLEMENTATION +#endif // #ifdef FCPP_STRING_IMPLEMENTATION + +// BOTTOM + diff --git a/test_data/lots_of_files/4coder_style.h b/test_data/lots_of_files/4coder_style.h new file mode 100644 index 0000000..7c88d18 --- /dev/null +++ b/test_data/lots_of_files/4coder_style.h @@ -0,0 +1,33 @@ +enum Style_Tag{ +Stag_Bar, +Stag_Bar_Active, +Stag_Base, +Stag_Pop1, +Stag_Pop2, +Stag_Back, +Stag_Margin, +Stag_Margin_Hover, +Stag_Margin_Active, +Stag_Cursor, +Stag_At_Cursor, +Stag_Highlight, +Stag_At_Highlight, +Stag_Mark, +Stag_Default, +Stag_Comment, +Stag_Keyword, +Stag_Str_Constant, +Stag_Char_Constant, +Stag_Int_Constant, +Stag_Float_Constant, +Stag_Bool_Constant, +Stag_Preproc, +Stag_Include, +Stag_Special_Character, +Stag_Highlight_Junk, +Stag_Highlight_White, +Stag_Paste, +Stag_Undo, +Stag_Next_Undo, +}; + diff --git a/test_data/lots_of_files/4coder_version.h b/test_data/lots_of_files/4coder_version.h new file mode 100644 index 0000000..871cab4 --- /dev/null +++ b/test_data/lots_of_files/4coder_version.h @@ -0,0 +1,15 @@ +#define MAJOR 4 +#define MINOR 0 +#define PATCH 1 + +#define VN__(a,b,c) #a"."#b"."#c +#define VN_(a,b,c) VN__(a,b,c) +#define VERSION_NUMBER VN_(MAJOR,MINOR,PATCH) +#define VERSION_STRING "alpha " VERSION_NUMBER + +#ifdef FRED_SUPER +#define VERSION_TYPE " super!" +#else +#define VERSION_TYPE +#endif +#define VERSION VERSION_STRING VERSION_TYPE diff --git a/test_data/lots_of_files/4cpp_clear_config.h b/test_data/lots_of_files/4cpp_clear_config.h new file mode 100644 index 0000000..1ee671c --- /dev/null +++ b/test_data/lots_of_files/4cpp_clear_config.h @@ -0,0 +1,54 @@ +/* "4cpp" Open C++ Parser v0.1: Clear Config + no warranty implied; use at your own risk + +NOTES ON USE: + This file is used to clear options. The main use for this is for cases when you want + it include different portions of the library with different settings. So that the compiler + does not complain about redifintion, and so that you do not have to undef everything yourself + this is provided to undef everything at once. +*/ + +#ifdef FCPP_NO_CRT +#undef FCPP_NO_CRT +#endif + +#ifdef FCPP_NO_MALLOC +#undef FCPP_NO_MALLOC +#endif + +#ifdef FCPP_NO_ASSERT +#undef FCPP_NO_ASSERT +#endif + +#ifdef FCPP_NO_STRING +#undef FCPP_NO_STRING +#endif + +#ifdef FCPP_GET_MEMORY +#undef FCPP_GET_MEMORY +#endif + +#ifdef FCPP_FREE_MEMORY +#undef FCPP_FREE_MEMORY +#endif + +#ifdef FCPP_ASSERT +#undef FCPP_ASSERT +#endif + +#ifdef FCPP_MEM_COPY +#undef FCPP_MEM_COPY +#endif + +#ifdef FCPP_MEM_MOVE +#undef FCPP_MEM_MOVE +#endif + +#ifdef FCPP_LINK +#undef FCPP_LINK +#endif + +#ifdef FCPP_EXTERN +#undef FCPP_EXTERN +#endif + diff --git a/test_data/lots_of_files/4cpp_lexer.h b/test_data/lots_of_files/4cpp_lexer.h new file mode 100644 index 0000000..837af0c --- /dev/null +++ b/test_data/lots_of_files/4cpp_lexer.h @@ -0,0 +1,1949 @@ +/* "4cpp" Open C++ Parser v0.1: Lexer + no warranty implied; use at your own risk + +NOTES ON USE: + OPTIONS: + Set options by defining macros before including this file. + + FCPP_LEXER_IMPLEMENTATION - causes this file to output function implementations + - this option is unset after use so that future includes of this file + in the same unit do not continue to output implementations + + FCPP_NO_MALLOC - prevent including <stdlib.h> + FCPP_NO_ASSERT - prevent including <assert.h> + FCPP_NO_STRING - prevent including <string.h> + FCPP_NO_CRT - FCPP_NO_MALLOC & FCPP_NO_ASSERT & FCPP_NO_STRING + + FCPP_FORBID_MALLOC - one step above *NO_MALLOC with this set 4cpp functions that do allocations + are not allowed to be declared or defined at all, forcing the user to handle + allocation themselves + - implies FCPP_NO_MALLOC + + FCPP_GET_MEMORY - defines how to make allocations, interface of malloc, defaults to malloc + FCPP_FREE_MEMORY - defines how to free memory, interface of ree, defaults to free + (The above must be defined if FCPP_NO_MALLOC is set, unless FCPP_FORBID_MALLOC is set) + + FCPP_ASSERT - defines how to make assertions, interface of assert, defaults to assert + + FCPP_MEM_COPY - defines how to copy blocks of memory, interface of memcpy, defaults to memcpy + FCPP_MEM_MOVE - defines how to move blocks of memory, interface of memmove, defaults to memmove + (The above must be defined if FCPP_NO_STRING is set) + + FCPP_LINK - defines linkage of non-inline functions, defaults to static + FCPP_EXTERN - changes FCPP_LINK default to extern, this option is ignored if FCPP_LINK is defined + + include the file "4cpp_clear_config.h" if you want to undefine all options for some reason + + HIDDDEN DEPENDENCIES: + 4cpp is not a single file include library, there are dependencies between the files. + Be sure to include these dependencies before 4cpp_lexer.h: + + 4cpp_types.h + 4cpp_string.h +*/ + +// TOP +// TODO(allen): +// +// EASE OF USE AND DEPLOYMENT +// - make it easier to locate the list of function declarations +// - more C compatibility +// +// POTENTIAL +// - Experiment with optimizations. Sean's State machine? +// - Reserve 0th token for null? Put a EOF token at the end? +// - Pass Cpp_File and Cpp_Token_Stack by value instead of by pointer? +// +// CURRENT +// - lex in chunks +// + +#include "4coder_config.h" + +#ifndef FCPP_LEXER_INC +#define FCPP_LEXER_INC + +enum Cpp_Token_Type{ + CPP_TOKEN_JUNK, + CPP_TOKEN_COMMENT, + + CPP_TOKEN_KEY_TYPE, + CPP_TOKEN_KEY_MODIFIER, + CPP_TOKEN_KEY_QUALIFIER, + CPP_TOKEN_KEY_OPERATOR, // NOTE(allen): This type is not actually stored in tokens + CPP_TOKEN_KEY_CONTROL_FLOW, + CPP_TOKEN_KEY_CAST, + CPP_TOKEN_KEY_TYPE_DECLARATION, + CPP_TOKEN_KEY_ACCESS, + CPP_TOKEN_KEY_LINKAGE, + CPP_TOKEN_KEY_OTHER, + + CPP_TOKEN_IDENTIFIER, + CPP_TOKEN_INTEGER_CONSTANT, + CPP_TOKEN_CHARACTER_CONSTANT, + CPP_TOKEN_FLOATING_CONSTANT, + CPP_TOKEN_STRING_CONSTANT, + CPP_TOKEN_BOOLEAN_CONSTANT, + + CPP_TOKEN_STATIC_ASSERT, + + CPP_TOKEN_BRACKET_OPEN, + CPP_TOKEN_BRACKET_CLOSE, + CPP_TOKEN_PARENTHESE_OPEN, + CPP_TOKEN_PARENTHESE_CLOSE, + CPP_TOKEN_BRACE_OPEN, + CPP_TOKEN_BRACE_CLOSE, + CPP_TOKEN_SEMICOLON, + CPP_TOKEN_ELLIPSIS, + + // NOTE(allen): Ambiguous tokens, lexer only, + // parser figures out the real meaning + CPP_TOKEN_STAR, + CPP_TOKEN_AMPERSAND, + CPP_TOKEN_TILDE, + CPP_TOKEN_PLUS, + CPP_TOKEN_MINUS, + CPP_TOKEN_INCREMENT, + CPP_TOKEN_DECREMENT, + + // NOTE(allen): Precedence 1, LtoR + CPP_TOKEN_SCOPE, + + // NOTE(allen): Precedence 2, LtoR + CPP_TOKEN_POSTINC, // from increment, parser only + CPP_TOKEN_POSTDEC, // from decrement, parser only + CPP_TOKEN_FUNC_STYLE_CAST, // parser only + CPP_TOKEN_CPP_STYLE_CAST, + CPP_TOKEN_CALL, // from open paren, parser only + CPP_TOKEN_INDEX, // from bracket open, parser only + CPP_TOKEN_DOT, + CPP_TOKEN_ARROW, + + // NOTE(allen): Precedence 3, RtoL + CPP_TOKEN_PREINC, // from increment, parser only + CPP_TOKEN_PREDEC, // from decrement, parser only + CPP_TOKEN_POSITIVE, // from plus, parser only + CPP_TOKEN_NEGAITVE, // from minus, parser only + CPP_TOKEN_NOT, + CPP_TOKEN_BIT_NOT, // from tilde, direct from 'compl' + CPP_TOKEN_CAST, // from open paren, parser only + CPP_TOKEN_DEREF, // from star, parser only + CPP_TOKEN_TYPE_PTR, // from star, parser only + CPP_TOKEN_ADDRESS, // from ampersand, parser only + CPP_TOKEN_TYPE_REF, // from ampersand, parser only + CPP_TOKEN_SIZEOF, + CPP_TOKEN_ALIGNOF, + CPP_TOKEN_DECLTYPE, + CPP_TOKEN_TYPEID, + CPP_TOKEN_NEW, + CPP_TOKEN_DELETE, + CPP_TOKEN_NEW_ARRAY, // from new and bracket open, parser only + CPP_TOKEN_DELETE_ARRAY, // from delete and bracket open, parser only + + // NOTE(allen): Precedence 4, LtoR + CPP_TOKEN_PTRDOT, + CPP_TOKEN_PTRARROW, + + // NOTE(allen): Precedence 5, LtoR + CPP_TOKEN_MUL, // from start, parser only + CPP_TOKEN_DIV, + CPP_TOKEN_MOD, + + // NOTE(allen): Precedence 6, LtoR + CPP_TOKEN_ADD, // from plus, parser only + CPP_TOKEN_SUB, // from minus, parser only + + // NOTE(allen): Precedence 7, LtoR + CPP_TOKEN_LSHIFT, + CPP_TOKEN_RSHIFT, + + // NOTE(allen): Precedence 8, LtoR + CPP_TOKEN_LESS, + CPP_TOKEN_GRTR, + CPP_TOKEN_GRTREQ, + CPP_TOKEN_LESSEQ, + + // NOTE(allen): Precedence 9, LtoR + CPP_TOKEN_EQEQ, + CPP_TOKEN_NOTEQ, + + // NOTE(allen): Precedence 10, LtoR + CPP_TOKEN_BIT_AND, // from ampersand, direct from 'bitand' + + // NOTE(allen): Precedence 11, LtoR + CPP_TOKEN_BIT_XOR, + + // NOTE(allen): Precedence 12, LtoR + CPP_TOKEN_BIT_OR, + + // NOTE(allen): Precedence 13, LtoR + CPP_TOKEN_AND, + + // NOTE(allen): Precedence 14, LtoR + CPP_TOKEN_OR, + + // NOTE(allen): Precedence 15, RtoL + CPP_TOKEN_TERNARY_QMARK, + CPP_TOKEN_COLON, + CPP_TOKEN_THROW, + CPP_TOKEN_EQ, + CPP_TOKEN_ADDEQ, + CPP_TOKEN_SUBEQ, + CPP_TOKEN_MULEQ, + CPP_TOKEN_DIVEQ, + CPP_TOKEN_MODEQ, + CPP_TOKEN_LSHIFTEQ, + CPP_TOKEN_RSHIFTEQ, + CPP_TOKEN_ANDEQ, + CPP_TOKEN_OREQ, + CPP_TOKEN_XOREQ, + + // NOTE(allen): Precedence 16, LtoR + CPP_TOKEN_COMMA, + + CPP_PP_INCLUDE, + CPP_PP_DEFINE, + CPP_PP_UNDEF, + CPP_PP_IF, + CPP_PP_IFDEF, + CPP_PP_IFNDEF, + CPP_PP_ELSE, + CPP_PP_ELIF, + CPP_PP_ENDIF, + CPP_PP_ERROR, + CPP_PP_IMPORT, + CPP_PP_USING, + CPP_PP_LINE, + CPP_PP_PRAGMA, + CPP_PP_STRINGIFY, + CPP_PP_CONCAT, + CPP_PP_UNKNOWN, + CPP_TOKEN_DEFINED, + CPP_TOKEN_INCLUDE_FILE, + CPP_TOKEN_ERROR_MESSAGE, + + // NOTE(allen): used in the parser + CPP_TOKEN_EOF +}; + +// TODO(allen): This is a dumb redundant type... probably just +// move towards using String for this everywhere eventually. +struct Cpp_File{ + char *data; + int size; +}; + +Cpp_File +data_as_cpp_file(Data data){ + Cpp_File result; + result.data = (char*)data.data; + result.size = data.size; + return(result); +} + +struct Cpp_Token{ + Cpp_Token_Type type; + fcpp_i32 start, size; + fcpp_u16 state_flags; + fcpp_u16 flags; +}; + +enum Cpp_Token_Flag{ + CPP_TFLAG_IGNORE = 1 << 0, + CPP_TFLAG_PP_DIRECTIVE = 1 << 1, + CPP_TFLAG_PP_BODY = 1 << 2, + CPP_TFLAG_BAD_ENDING = 1 << 3, + CPP_TFLAG_MULTILINE = 1 << 4, + CPP_TFLAG_PARAMETERIZED = 1 << 5, + CPP_TFLAG_IS_OPERATOR = 1 << 6, + CPP_TFLAG_IS_KEYWORD = 1 << 7 +}; + +enum Cpp_Preprocessor_State{ + CPP_LEX_PP_DEFAULT, + CPP_LEX_PP_IDENTIFIER, + CPP_LEX_PP_MACRO_IDENTIFIER, + CPP_LEX_PP_INCLUDE, + CPP_LEX_PP_BODY, + CPP_LEX_PP_BODY_IF, + CPP_LEX_PP_NUMBER, + CPP_LEX_PP_ERROR, + CPP_LEX_PP_JUNK, + // NEVER ADD BELOW THIS + CPP_LEX_PP_COUNT +}; + +struct Cpp_Lex_Data{ + Cpp_Preprocessor_State pp_state; + fcpp_i32 pos; + fcpp_bool32 complete; +}; + +struct Cpp_Read_Result{ + Cpp_Token token; + fcpp_i32 pos; + fcpp_bool8 newline; + fcpp_bool8 has_result; +}; + +struct Cpp_Token_Stack{ + Cpp_Token *tokens; + int count, max_count; +}; + +struct Cpp_Token_Merge{ + Cpp_Token new_token; + fcpp_bool32 did_merge; +}; + +struct Seek_Result{ + fcpp_i32 pos; + fcpp_bool32 new_line; +}; + +struct Cpp_Get_Token_Result{ + fcpp_i32 token_index; + fcpp_bool32 in_whitespace; +}; + +// TODO(allen): revisit this keyword data declaration system +struct String_And_Flag{ + char *str; + fcpp_u32 flags; +}; + +struct String_List{ + String_And_Flag *data; + int count; +}; + +struct Sub_Match_List_Result{ + int index; + fcpp_i32 new_pos; +}; + +inline fcpp_u16 +cpp_token_set_pp_state(fcpp_u16 bitfield, Cpp_Preprocessor_State state_value){ + return (fcpp_u16)state_value; +} + +inline Cpp_Preprocessor_State +cpp_token_get_pp_state(fcpp_u16 bitfield){ + return (Cpp_Preprocessor_State)(bitfield); +} + +inline String +cpp_get_lexeme(char *str, Cpp_Token *token){ + String result; + result.str = str + token->start; + result.size = token->size; + return result; +} + +inline bool +is_keyword(Cpp_Token_Type type){ + return (type >= CPP_TOKEN_KEY_TYPE && type <= CPP_TOKEN_KEY_OTHER); +} + +FCPP_LINK Sub_Match_List_Result sub_match_list(Cpp_File file, int pos, String_List list, int sub_size); + +FCPP_LINK Seek_Result seek_unescaped_eol(char *data, int size, int pos); +FCPP_LINK Seek_Result seek_unescaped_delim(char *data, int size, int pos, char delim); +FCPP_LINK Seek_Result seek_block_comment_end(char *data, int size, int pos); + +FCPP_LINK Cpp_Read_Result cpp_read_whitespace(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_junk_line(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_operator(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_pp_operator(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_alpha_numeric(Cpp_File file, int pos, bool in_if_body); +inline Cpp_Read_Result cpp_read_alpha_numeric(Cpp_File file, int pos) { return cpp_read_alpha_numeric(file, pos, 0); } +FCPP_LINK Cpp_Read_Result cpp_read_number(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_string_litteral(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_character_litteral(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_line_comment(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_block_comment(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_preprocessor(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_pp_include_file(Cpp_File file, int pos); +FCPP_LINK Cpp_Read_Result cpp_read_pp_default_mode(Cpp_File file, int pos, bool in_if_body); +inline Cpp_Read_Result cpp_read_pp_default_mode(Cpp_File file, int pos) { return cpp_read_pp_default_mode(file, pos, 0); } + +FCPP_LINK Cpp_Token_Merge cpp_attempt_token_merge(Cpp_Token prev, Cpp_Token next); + +FCPP_LINK bool cpp_push_token_no_merge(Cpp_Token_Stack *stack, Cpp_Token token); +FCPP_LINK bool cpp_push_token_nonalloc(Cpp_Token_Stack *stack, Cpp_Token token); + +FCPP_LINK Cpp_Read_Result cpp_lex_step(Cpp_File file, Cpp_Lex_Data *lex); + +FCPP_LINK int cpp_lex_file_token_count(Cpp_File file); +FCPP_LINK Cpp_Lex_Data cpp_lex_file_nonalloc(Cpp_File file, Cpp_Token_Stack *stack, Cpp_Lex_Data data); +inline Cpp_Lex_Data cpp_lex_file_nonalloc(Cpp_File file, Cpp_Token_Stack *stack) { return cpp_lex_file_nonalloc(file, stack, {}); } + +FCPP_LINK Cpp_Get_Token_Result cpp_get_token(Cpp_Token_Stack *stack, int pos); + +FCPP_LINK int cpp_get_end_token(Cpp_Token_Stack *stack, int end); +FCPP_LINK void cpp_shift_token_starts(Cpp_Token_Stack *stack, int from_token, int amount); + +struct Cpp_Relex_State{ + Cpp_File file; + Cpp_Token_Stack *stack; + int start, end, amount; + int start_token_i; + int end_token_i; + int relex_start; + int tolerance; + int space_request; +}; + +FCPP_LINK Cpp_Relex_State cpp_relex_nonalloc_start(Cpp_File file, Cpp_Token_Stack *stack, int start, int end, int amount, int tolerance); +FCPP_LINK bool cpp_relex_nonalloc_main(Cpp_Relex_State state, Cpp_Token_Stack *stack); + +#ifndef FCPP_FORBID_MALLOC +FCPP_LINK Cpp_Token_Stack cpp_make_token_stack(int max); +FCPP_LINK void cpp_free_token_stack(Cpp_Token_Stack stack); +FCPP_LINK void cpp_resize_token_stack(Cpp_Token_Stack *stack, int new_max); + +FCPP_LINK void cpp_push_token(Cpp_Token_Stack *stack, Cpp_Token token); +FCPP_LINK void cpp_lex_file(Cpp_File file, Cpp_Token_Stack *stack); +FCPP_LINK bool cpp_relex_file_limited(Cpp_File file, Cpp_Token_Stack *stack, int start_i, int end_i, int amount, int extra_tolerance); +inline void cpp_relex_file(Cpp_File file, Cpp_Token_Stack *stack, int start_i, int end_i, int amount) +{ cpp_relex_file_limited(file, stack, start_i, end_i, amount, -1); } +#endif + +#define FCPP_STRING_LIST(x) {x, FCPP_COUNT(x)} + +// TODO(allen): shift towards storing in a context +FCPP_GLOBAL String_And_Flag int_suf_strings[] = { + {"ull"}, {"ULL"}, + {"llu"}, {"LLU"}, + {"ll"}, {"LL"}, + {"l"}, {"L"}, + {"u"}, {"U"} +}; + +FCPP_GLOBAL String_List int_sufs = FCPP_STRING_LIST(int_suf_strings); + +FCPP_GLOBAL String_And_Flag float_suf_strings[] = { + {"f"}, {"F"}, + {"l"}, {"L"} +}; +FCPP_GLOBAL String_List float_sufs = FCPP_STRING_LIST(float_suf_strings); + +FCPP_GLOBAL String_And_Flag bool_lit_strings[] = { + {"true"}, {"false"} +}; +FCPP_GLOBAL String_List bool_lits = FCPP_STRING_LIST(bool_lit_strings); + +FCPP_GLOBAL String_And_Flag keyword_strings[] = { + {"and", CPP_TOKEN_AND}, + {"and_eq", CPP_TOKEN_ANDEQ}, + {"bitand", CPP_TOKEN_BIT_AND}, + {"bitor", CPP_TOKEN_BIT_OR}, + {"or", CPP_TOKEN_OR}, + {"or_eq", CPP_TOKEN_OREQ}, + {"sizeof", CPP_TOKEN_SIZEOF}, + {"alignof", CPP_TOKEN_ALIGNOF}, + {"decltype", CPP_TOKEN_DECLTYPE}, + {"throw", CPP_TOKEN_THROW}, + {"new", CPP_TOKEN_NEW}, + {"delete", CPP_TOKEN_DELETE}, + {"xor", CPP_TOKEN_BIT_XOR}, + {"xor_eq", CPP_TOKEN_XOREQ}, + {"not", CPP_TOKEN_NOT}, + {"not_eq", CPP_TOKEN_NOTEQ}, + {"typeid", CPP_TOKEN_TYPEID}, + {"compl", CPP_TOKEN_BIT_NOT}, + + {"void", CPP_TOKEN_KEY_TYPE}, + {"bool", CPP_TOKEN_KEY_TYPE}, + {"char", CPP_TOKEN_KEY_TYPE}, + {"int", CPP_TOKEN_KEY_TYPE}, + {"float", CPP_TOKEN_KEY_TYPE}, + {"double", CPP_TOKEN_KEY_TYPE}, + + {"long", CPP_TOKEN_KEY_MODIFIER}, + {"short", CPP_TOKEN_KEY_MODIFIER}, + {"unsigned", CPP_TOKEN_KEY_MODIFIER}, + + {"const", CPP_TOKEN_KEY_QUALIFIER}, + {"volatile", CPP_TOKEN_KEY_QUALIFIER}, + + {"asm", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"break", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"case", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"catch", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"continue", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"default", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"do", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"else", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"for", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"goto", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"if", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"return", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"switch", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"try", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"while", CPP_TOKEN_KEY_CONTROL_FLOW}, + {"static_assert", CPP_TOKEN_KEY_CONTROL_FLOW}, + + {"const_cast", CPP_TOKEN_KEY_CAST}, + {"dynamic_cast", CPP_TOKEN_KEY_CAST}, + {"reinterpret_cast", CPP_TOKEN_KEY_CAST}, + {"static_cast", CPP_TOKEN_KEY_CAST}, + + {"class", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"enum", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"struct", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"typedef", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"union", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"template", CPP_TOKEN_KEY_TYPE_DECLARATION}, + {"typename", CPP_TOKEN_KEY_TYPE_DECLARATION}, + + {"friend", CPP_TOKEN_KEY_ACCESS}, + {"namespace", CPP_TOKEN_KEY_ACCESS}, + {"private", CPP_TOKEN_KEY_ACCESS}, + {"protected", CPP_TOKEN_KEY_ACCESS}, + {"public", CPP_TOKEN_KEY_ACCESS}, + {"using", CPP_TOKEN_KEY_ACCESS}, + + {"extern", CPP_TOKEN_KEY_LINKAGE}, + {"export", CPP_TOKEN_KEY_LINKAGE}, + {"inline", CPP_TOKEN_KEY_LINKAGE}, + {"static", CPP_TOKEN_KEY_LINKAGE}, + {"virtual", CPP_TOKEN_KEY_LINKAGE}, + + {"alignas", CPP_TOKEN_KEY_OTHER}, + {"explicit", CPP_TOKEN_KEY_OTHER}, + {"noexcept", CPP_TOKEN_KEY_OTHER}, + {"nullptr", CPP_TOKEN_KEY_OTHER}, + {"operator", CPP_TOKEN_KEY_OTHER}, + {"register", CPP_TOKEN_KEY_OTHER}, + {"this", CPP_TOKEN_KEY_OTHER}, + {"thread_local", CPP_TOKEN_KEY_OTHER}, +}; +FCPP_GLOBAL String_List keywords = FCPP_STRING_LIST(keyword_strings); + +FCPP_GLOBAL String_And_Flag op_strings[] = { + {"...", CPP_TOKEN_ELLIPSIS}, + {"<<=", CPP_TOKEN_LSHIFTEQ}, + {">>=", CPP_TOKEN_RSHIFTEQ}, + {"->*", CPP_TOKEN_PTRARROW}, + {"<<", CPP_TOKEN_LSHIFT}, + {">>", CPP_TOKEN_RSHIFT}, + {"&&", CPP_TOKEN_AND}, + {"||", CPP_TOKEN_OR}, + {"->", CPP_TOKEN_ARROW}, + {"++", CPP_TOKEN_INCREMENT}, + {"--", CPP_TOKEN_DECREMENT}, + {"::", CPP_TOKEN_SCOPE}, + {"+=", CPP_TOKEN_ADDEQ}, + {"-=", CPP_TOKEN_SUBEQ}, + {"*=", CPP_TOKEN_MULEQ}, + {"/=", CPP_TOKEN_DIVEQ}, + {"%=", CPP_TOKEN_MODEQ}, + {"&=", CPP_TOKEN_ANDEQ}, + {"|=", CPP_TOKEN_OREQ}, + {"^=", CPP_TOKEN_XOREQ}, + {"==", CPP_TOKEN_EQEQ}, + {">=", CPP_TOKEN_GRTREQ}, + {"<=", CPP_TOKEN_LESSEQ}, + {"!=", CPP_TOKEN_NOTEQ}, + {".*", CPP_TOKEN_PTRDOT}, + {"{", CPP_TOKEN_BRACE_OPEN}, + {"}", CPP_TOKEN_BRACE_CLOSE}, + {"[", CPP_TOKEN_BRACKET_OPEN}, + {"]", CPP_TOKEN_BRACKET_CLOSE}, + {"(", CPP_TOKEN_PARENTHESE_OPEN}, + {")", CPP_TOKEN_PARENTHESE_CLOSE}, + {"<", CPP_TOKEN_LESS}, + {">", CPP_TOKEN_GRTR}, + {"+", CPP_TOKEN_PLUS}, + {"-", CPP_TOKEN_MINUS}, + {"!", CPP_TOKEN_NOT}, + {"~", CPP_TOKEN_TILDE}, + {"*", CPP_TOKEN_STAR}, + {"&", CPP_TOKEN_AMPERSAND}, + {"|", CPP_TOKEN_BIT_OR}, + {"^", CPP_TOKEN_BIT_XOR}, + {"=", CPP_TOKEN_EQ}, + {",", CPP_TOKEN_COMMA}, + {":", CPP_TOKEN_COLON}, + {";", CPP_TOKEN_SEMICOLON}, + {"/", CPP_TOKEN_DIV}, + {"?", CPP_TOKEN_TERNARY_QMARK}, + {"%", CPP_TOKEN_MOD}, + {".", CPP_TOKEN_DOT}, +}; +FCPP_GLOBAL String_List ops = FCPP_STRING_LIST(op_strings); + +FCPP_GLOBAL String_And_Flag pp_op_strings[] = { + {"##", CPP_PP_CONCAT}, + {"#", CPP_PP_STRINGIFY}, +}; +FCPP_GLOBAL String_List pp_ops = FCPP_STRING_LIST(pp_op_strings); + +FCPP_GLOBAL String_And_Flag preprop_strings[] = { + {"include", CPP_PP_INCLUDE}, + {"INCLUDE", CPP_PP_INCLUDE}, + {"ifndef", CPP_PP_IFNDEF}, + {"IFNDEF", CPP_PP_IFNDEF}, + {"define", CPP_PP_DEFINE}, + {"DEFINE", CPP_PP_DEFINE}, + {"import", CPP_PP_IMPORT}, + {"IMPORT", CPP_PP_IMPORT}, + {"pragma", CPP_PP_PRAGMA}, + {"PRAGMA", CPP_PP_PRAGMA}, + {"undef", CPP_PP_UNDEF}, + {"UNDEF", CPP_PP_UNDEF}, + {"endif", CPP_PP_ENDIF}, + {"ENDIF", CPP_PP_ENDIF}, + {"error", CPP_PP_ERROR}, + {"ERROR", CPP_PP_ERROR}, + {"ifdef", CPP_PP_IFDEF}, + {"IFDEF", CPP_PP_IFDEF}, + {"using", CPP_PP_USING}, + {"USING", CPP_PP_USING}, + {"else", CPP_PP_ELSE}, + {"ELSE", CPP_PP_ELSE}, + {"elif", CPP_PP_ELIF}, + {"ELIF", CPP_PP_ELIF}, + {"line", CPP_PP_LINE}, + {"LINE", CPP_PP_LINE}, + {"if", CPP_PP_IF}, + {"IF", CPP_PP_IF}, +}; +FCPP_GLOBAL String_List preprops = FCPP_STRING_LIST(preprop_strings); + +#undef FCPP_STRING_LIST + +#endif // #ifndef FCPP_CPP_LEXER + +#ifdef FCPP_LEXER_IMPLEMENTATION + +#define _Assert FCPP_ASSERT +#define _TentativeAssert FCPP_ASSERT + +FCPP_LINK Sub_Match_List_Result +sub_match_list(Cpp_File file, int pos, String_List list, int sub_size){ + Sub_Match_List_Result result; + String str_main; + char *str_check; + int i,l; + + result.index = -1; + result.new_pos = pos; + str_main = make_string(file.data + pos, file.size - pos); + if (sub_size > 0){ + str_main = substr(str_main, 0, sub_size); + for (i = 0; i < list.count; ++i){ + str_check = list.data[i].str; + if (match(str_main, str_check)){ + result.index = i; + result.new_pos = pos + sub_size; + break; + } + } + } + else{ + for (i = 0; i < list.count; ++i){ + str_check = list.data[i].str; + if (match_part(str_main, str_check, &l)){ + result.index = i; + result.new_pos = pos + l; + break; + } + } + } + return result; +} + +FCPP_LINK Seek_Result +seek_unescaped_eol(char *data, int size, int pos){ + Seek_Result result = {}; + ++pos; + while (pos < size){ + if (data[pos] == '\\'){ + if (pos + 1 < size && + data[pos+1] == '\n'){ + result.new_line = 1; + ++pos; + } + else if (pos + 1 < size && + data[pos+1] == '\r' && + pos + 2 < size && + data[pos+2] == '\n'){ + result.new_line = 1; + pos += 2; + } + } + else if (data[pos] == '\n'){ + break; + } + ++pos; + } + ++pos; + + result.pos = pos; + return result; +} + +FCPP_LINK Seek_Result +seek_unescaped_delim(char *data, int size, int pos, char delim){ + Seek_Result result = {}; + bool escape = 0; + ++pos; + while (pos < size){ + if (data[pos] == '\n'){ + result.new_line = 1; + } + if (escape){ + escape = 0; + } + else{ + if (data[pos] == '\\'){ + escape = 1; + } + else if (data[pos] == delim){ + break; + } + } + ++pos; + } + ++pos; + + result.pos = pos; + return result; +} + +FCPP_LINK Seek_Result +seek_block_comment_end(char *data, int size, int pos){ + Seek_Result result = {}; + pos += 2; + while (pos < size){ + if (data[pos] == '*' && + pos + 1 < size && + data[pos+1] == '/'){ + break; + } + if (data[pos] == '\n'){ + result.new_line = 1; + } + ++pos; + } + pos += 2; + result.pos = pos; + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_whitespace(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + + while (pos < file.size && char_is_whitespace(file.data[pos])){ + if (file.data[pos] == '\n'){ + result.newline = 1; + } + ++pos; + } + + result.pos = pos; + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_junk_line(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.token.start = pos; + result.token.type = CPP_TOKEN_JUNK; + + bool comment_end = 0; + while (pos < file.size && file.data[pos] != '\n'){ + if (file.data[pos] == '/' && pos + 1 < file.size){ + if (file.data[pos + 1] == '/' || + file.data[pos + 1] == '*'){ + comment_end = 1; + break; + } + } + ++pos; + } + + if (comment_end){ + result.pos = pos; + result.token.size = pos - result.token.start; + } + else{ + while (pos > 0 && file.data[pos - 1] == '\r'){ + --pos; + } + if (pos > 0 && file.data[pos - 1] == '\\'){ + --pos; + } + result.pos = pos; + result.token.size = pos - result.token.start; + } + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_operator(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.pos = pos; + result.token.start = pos; + + Sub_Match_List_Result match; + match = sub_match_list(file, result.token.start, ops, -1); + + if (match.index != -1){ + result.pos = match.new_pos; + result.token.size = result.pos - result.token.start; + result.token.type = (Cpp_Token_Type)ops.data[match.index].flags; + result.token.flags |= CPP_TFLAG_IS_OPERATOR; + } + else{ + result.token.size = 1; + result.token.type = CPP_TOKEN_JUNK; + result.pos = pos + 1; + } + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_pp_operator(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.pos = pos; + result.token.start = pos; + + Sub_Match_List_Result match; + match = sub_match_list(file, result.token.start, pp_ops, -1); + + _Assert(match.index != -1); + result.pos = match.new_pos; + result.token.size = result.pos - result.token.start; + result.token.type = (Cpp_Token_Type)pp_ops.data[match.index].flags; + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_alpha_numeric(Cpp_File file, int pos, bool in_if_body){ + Cpp_Read_Result result = {}; + result.pos = pos; + result.token.start = pos; + + while (result.pos < file.size && + char_is_alpha_numeric(file.data[result.pos])){ + ++result.pos; + } + + result.token.size = result.pos - result.token.start; + + // TODO(allen): do better + if (in_if_body){ + String word; + word.size = result.token.size; + word.str = file.data + result.token.start; + if (match(word, "defined")){ + result.token.type = CPP_TOKEN_DEFINED; + result.token.flags |= CPP_TFLAG_IS_OPERATOR; + result.token.flags |= CPP_TFLAG_IS_KEYWORD; + } + } + + if (result.token.type == CPP_TOKEN_JUNK){ + Sub_Match_List_Result match; + match = sub_match_list(file, result.token.start, bool_lits, result.token.size); + + if (match.index != -1){ + result.token.type = CPP_TOKEN_BOOLEAN_CONSTANT; + result.token.flags |= CPP_TFLAG_IS_KEYWORD; + } + else{ + match = sub_match_list(file, result.token.start, keywords, result.token.size); + + if (match.index != -1){ + String_And_Flag data = keywords.data[match.index]; + result.token.type = (Cpp_Token_Type)data.flags; + result.token.flags |= CPP_TFLAG_IS_KEYWORD; + } + else{ + result.token.type = CPP_TOKEN_IDENTIFIER; + } + } + } + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_number(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.pos = pos; + result.token.start = pos; + + bool is_float = 0; + bool is_integer = 0; + bool is_oct = 0; + bool is_hex = 0; + bool is_zero = 0; + + if (file.data[pos] == '0'){ + if (pos+1 < file.size){ + char next = file.data[pos+1]; + if (next == 'x'){ + is_hex = 1; + is_integer = 1; + } + else if (next == '.'){ + is_float = 1; + ++result.pos; + } + else if (next >= '0' && next <= '9'){ + is_oct = 1; + is_integer = 1; + } + else{ + is_zero = 1; + is_integer = 1; + } + } + else{ + is_zero = 1; + is_integer = 1; + } + } + else if (file.data[pos] == '.'){ + is_float = 1; + } + + if (is_zero){ + ++result.pos; + } + else if (is_hex){ + ++result.pos; + char character; + do{ + ++result.pos; + if (result.pos >= file.size){ + break; + } + character = file.data[result.pos]; + } while(char_is_hex(character)); + } + else if (is_oct){ + char character; + do{ + ++result.pos; + if (result.pos >= file.size){ + break; + } + character = file.data[result.pos]; + }while(char_is_numeric(character)); + } + else{ + if (!is_float){ + is_integer = 1; + while (1){ + ++result.pos; + + if (result.pos >= file.size){ + break; + } + bool is_good = 0; + char character = file.data[result.pos]; + if (character >= '0' && character <= '9'){ + is_good = 1; + } + else if (character == '.'){ + is_integer = 0; + is_float = 1; + } + if (!is_good){ + break; + } + } + } + + if (is_float){ + bool e_mode = 0; + bool e_minus = 0; + bool is_good = 0; + char character; + + while (1){ + ++result.pos; + if (result.pos >= file.size){ + break; + } + is_good = 0; + character = file.data[result.pos]; + if (character >= '0' && character <= '9'){ + is_good = 1; + } + else{ + if (character == 'e' && !e_mode){ + e_mode = 1; + is_good = 1; + } + else if (character == '-' && e_mode && !e_minus){ + e_minus = 1; + is_good = 1; + } + } + if (!is_good){ + break; + } + } + } + } + + if (is_integer){ + Sub_Match_List_Result match = + sub_match_list(file, result.pos, int_sufs, -1); + if (match.index != -1){ + result.pos = match.new_pos; + } + result.token.type = CPP_TOKEN_INTEGER_CONSTANT; + result.token.size = result.pos - result.token.start; + } + else if (is_float){ + Sub_Match_List_Result match = + sub_match_list(file, result.pos, float_sufs, -1); + if (match.index != -1){ + result.pos = match.new_pos; + } + result.token.type = CPP_TOKEN_FLOATING_CONSTANT; + result.token.size = result.pos - result.token.start; + } + else{ + _Assert(!"This shouldn't happen!"); + } + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_string_litteral(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.token.start = pos; + + _Assert(file.data[pos] == '"'); + Seek_Result seek = seek_unescaped_delim(file.data, file.size, pos, '"'); + pos = seek.pos; + if (seek.new_line){ + result.token.flags |= CPP_TFLAG_MULTILINE; + } + + result.token.size = pos - result.token.start; + result.token.type = CPP_TOKEN_STRING_CONSTANT; + result.pos = pos; + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_character_litteral(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.token.start = pos; + + _Assert(file.data[pos] == '\''); + Seek_Result seek = seek_unescaped_delim(file.data, file.size, pos, '\''); + pos = seek.pos; + if (seek.new_line){ + result.token.flags |= CPP_TFLAG_MULTILINE; + } + + result.token.size = pos - result.token.start; + result.token.type = CPP_TOKEN_CHARACTER_CONSTANT; + result.pos = pos; + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_line_comment(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.token.start = pos; + + _Assert(file.data[pos] == '/' && file.data[pos + 1] == '/'); + + pos += 2; + while (pos < file.size){ + if (file.data[pos] == '\n'){ + break; + } + if (file.data[pos] == '\\'){ + if (pos + 1 < file.size && + file.data[pos + 1] == '\n'){ + ++pos; + } + else if (pos + 2 < file.size && + file.data[pos + 1] == '\r' && + file.data[pos + 2] == '\n'){ + pos += 2; + } + } + ++pos; + } + if (pos > 0 && file.data[pos-1] == '\r'){ + --pos; + } + result.token.size = pos - result.token.start; + result.token.type = CPP_TOKEN_COMMENT; + result.pos = pos; + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_block_comment(Cpp_File file, int pos){ + Cpp_Read_Result result = {}; + result.token.start = pos; + + _Assert(file.data[pos] == '/' && file.data[pos + 1] == '*'); + pos += 2; + while (pos < file.size){ + if (file.data[pos] == '*' && + pos + 1 < file.size && + file.data[pos+1] == '/'){ + break; + } + ++pos; + } + pos += 2; + result.token.size = pos - result.token.start; + result.token.type = CPP_TOKEN_COMMENT; + result.pos = pos; + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_preprocessor(Cpp_File file, int pos){ + _Assert(file.data[pos] == '#'); + Cpp_Read_Result result = {}; + result.token.start = pos; + result.token.type = CPP_PP_UNKNOWN; + result.token.flags |= CPP_TFLAG_PP_DIRECTIVE; + + ++pos; + while (pos < file.size && + (file.data[pos] == ' ' || + file.data[pos] == '\t')){ + ++pos; + } + + Sub_Match_List_Result match + = sub_match_list(file, pos, preprops, -1); + + if (match.index != -1){ + result.token.size = match.new_pos - result.token.start; + result.token.type = (Cpp_Token_Type)preprops.data[match.index].flags; + result.pos = match.new_pos; + } + else{ + while (pos < file.size && + !char_is_whitespace(file.data[pos])){ + ++pos; + } + result.token.size = pos - result.token.start; + result.pos = pos; + } + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_pp_include_file(Cpp_File file, int pos){ + char start = file.data[pos]; + _Assert(start == '<' || start == '"'); + + Cpp_Read_Result result = {}; + result.token.start = pos; + result.token.type = CPP_TOKEN_INCLUDE_FILE; + result.token.flags |= CPP_TFLAG_PP_BODY; + + char end; + if (start == '<'){ + end = '>'; + } + else{ + end = '"'; + } + + ++pos; + while (pos < file.size && file.data[pos] != end){ + if (file.data[pos] == '\n'){ + result.token.type = CPP_TOKEN_JUNK; + result.token.flags |= CPP_TFLAG_BAD_ENDING; + break; + } + if (file.data[pos] == '\\'){ + // TODO(allen): Not sure that this is 100% correct. + if (pos + 1 < file.size && + file.data[pos + 1] == '\n'){ + ++pos; + result.token.flags |= CPP_TFLAG_MULTILINE; + } + else if (pos + 2 < file.size && + file.data[pos + 1] == '\r' && + file.data[pos + 2] == '\n'){ + pos += 2; + result.token.flags |= CPP_TFLAG_MULTILINE; + } + } + ++pos; + } + + if (result.token.type != CPP_TOKEN_JUNK){ + if (pos < file.size){ + ++pos; + } + } + + result.token.size = pos - result.token.start; + result.pos = pos; + + return result; +} + +FCPP_LINK Cpp_Read_Result +cpp_read_pp_default_mode(Cpp_File file, int pos, bool in_if_body){ + char current = file.data[pos]; + Cpp_Read_Result result; + if (char_is_numeric(current)){ + result = cpp_read_number(file, pos); + } + else if (char_is_alpha(current)){ + result = cpp_read_alpha_numeric(file, pos, in_if_body); + } + else if (current == '.'){ + if (pos + 1 < file.size){ + char next = file.data[pos + 1]; + if (char_is_numeric(next)){ + result = cpp_read_number(file, pos); + } + else{ + result = cpp_read_operator(file, pos); + } + } + else{ + result = cpp_read_operator(file, pos); + } + } + + else if (current == '/'){ + if (pos + 1 < file.size){ + char next = file.data[pos + 1]; + if (next == '/'){ + result = cpp_read_line_comment(file, pos); + } + else if (next == '*'){ + result = cpp_read_block_comment(file, pos); + } + else{ + result = cpp_read_operator(file, pos); + } + } + else{ + result = cpp_read_operator(file, pos); + } + } + else if (current == '"'){ + result = cpp_read_string_litteral(file, pos); + } + else if (current == '\''){ + result = cpp_read_character_litteral(file, pos); + } + else{ + result = cpp_read_operator(file, pos); + } + + return result; +} + +FCPP_LINK Cpp_Token_Merge +cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){ + Cpp_Token_Merge result = {}; + if (next_token.type == CPP_TOKEN_COMMENT && prev_token.type == CPP_TOKEN_COMMENT && + next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){ + result.did_merge = 1; + prev_token.size = next_token.start + next_token.size - prev_token.start; + result.new_token = prev_token; + } + else if (next_token.type == CPP_TOKEN_JUNK && prev_token.type == CPP_TOKEN_JUNK && + next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){ + result.did_merge = 1; + prev_token.size = next_token.start + next_token.size - prev_token.start; + result.new_token = prev_token; + } + return result; +} + +FCPP_LINK bool +cpp_push_token_no_merge(Cpp_Token_Stack *token_stack, Cpp_Token token){ + if (token_stack->count >= token_stack->max_count){ + return 0; + } + + token_stack->tokens[token_stack->count++] = token; + return 1; +} + +FCPP_LINK bool +cpp_push_token_nonalloc(Cpp_Token_Stack *token_stack, Cpp_Token token){ + Cpp_Token_Merge merge = {}; + + if (token_stack->count > 0){ + Cpp_Token prev_token = token_stack->tokens[token_stack->count - 1]; + merge = cpp_attempt_token_merge(prev_token, token); + if (merge.did_merge){ + token_stack->tokens[token_stack->count - 1] = merge.new_token; + } + } + + if (!merge.did_merge){ + if (token_stack->count >= token_stack->max_count){ + return 0; + } + + token_stack->tokens[token_stack->count++] = token; + } + + return 1; +} + +FCPP_LINK Cpp_Read_Result +cpp_lex_step(Cpp_File file, Cpp_Lex_Data *lex_data){ + Cpp_Lex_Data lex = *lex_data; + Cpp_Read_Result result = {}; + bool has_result = 1; + + fcpp_u16 state_flags = cpp_token_set_pp_state(0, lex.pp_state); + + char current = file.data[lex.pos]; + if (char_is_whitespace(current)){ + result = cpp_read_whitespace(file, lex.pos); + lex.pos = result.pos; + if (result.newline && lex.pp_state != CPP_LEX_PP_DEFAULT){ + lex.pp_state = CPP_LEX_PP_DEFAULT; + } + has_result = 0; + } + + else{ + if (lex.pp_state == CPP_LEX_PP_DEFAULT){ + // TODO(allen): Not first hard of the line? Then it's junk. + if (current == '#'){ + result = cpp_read_preprocessor(file, lex.pos); + lex.pos = result.pos; + switch (result.token.type){ + case CPP_PP_INCLUDE: + case CPP_PP_IMPORT: + case CPP_PP_USING: + lex.pp_state = CPP_LEX_PP_INCLUDE; + break; + case CPP_PP_DEFINE: + lex.pp_state = CPP_LEX_PP_MACRO_IDENTIFIER; + break; + case CPP_PP_UNDEF: + case CPP_PP_IFDEF: + case CPP_PP_IFNDEF: + lex.pp_state = CPP_LEX_PP_IDENTIFIER; + break; + case CPP_PP_IF: + case CPP_PP_ELIF: + lex.pp_state = CPP_LEX_PP_BODY_IF; + break; + case CPP_PP_PRAGMA: + lex.pp_state = CPP_LEX_PP_BODY; + break; + case CPP_PP_LINE: + lex.pp_state = CPP_LEX_PP_NUMBER; + break; + case CPP_PP_ERROR: + lex.pp_state = CPP_LEX_PP_ERROR; + break; + + case CPP_PP_UNKNOWN: + case CPP_PP_ELSE: + case CPP_PP_ENDIF: + lex.pp_state = CPP_LEX_PP_JUNK; + break; + } + } + else{ + result = cpp_read_pp_default_mode(file, lex.pos); + lex.pos = result.pos; + } + } + + else{ + if (current == '\\'){ + fcpp_i32 seek = lex.pos; + ++seek; + while (seek < file.size && file.data[seek] == '\r'){ + ++seek; + } + if ((seek < file.size && file.data[seek] == '\n') || seek >= file.size){ + lex.pos = seek + 1; + has_result = 0; + } + else{ + lex.pp_state = CPP_LEX_PP_JUNK; + result.token.type = CPP_TOKEN_JUNK; + result.token.start = lex.pos; + result.token.size = 1; + result.token.flags |= CPP_TFLAG_PP_BODY; + lex.pos = seek; + } + } + + else{ + switch (lex.pp_state){ + case CPP_LEX_PP_IDENTIFIER: + if (!char_is_alpha_numeric(current)){ + has_result = 0; + lex.pp_state = CPP_LEX_PP_JUNK; + } + else{ + result = cpp_read_alpha_numeric(file, lex.pos); + result.token.flags |= CPP_TFLAG_PP_BODY; + lex.pos = result.pos; + lex.pp_state = CPP_LEX_PP_JUNK; + } + break; + + case CPP_LEX_PP_MACRO_IDENTIFIER: + if (!char_is_alpha_numeric(current)){ + has_result = 0; + lex.pp_state = CPP_LEX_PP_JUNK; + } + else{ + result = cpp_read_alpha_numeric(file, lex.pos); + result.token.flags |= CPP_TFLAG_PP_BODY; + lex.pos = result.pos; + lex.pp_state = CPP_LEX_PP_BODY; + } + break; + + case CPP_LEX_PP_INCLUDE: + if (current != '"' && current != '<'){ + has_result = 0; + lex.pp_state = CPP_LEX_PP_JUNK; + } + else{ + result = cpp_read_pp_include_file(file, lex.pos); + lex.pos = result.pos; + lex.pp_state = CPP_LEX_PP_JUNK; + } + break; + + case CPP_LEX_PP_BODY: + if (current == '#'){ + result = cpp_read_pp_operator(file, lex.pos); + } + else{ + result = cpp_read_pp_default_mode(file, lex.pos); + } + lex.pos = result.pos; + result.token.flags |= CPP_TFLAG_PP_BODY; + break; + + case CPP_LEX_PP_BODY_IF: + if (current == '#'){ + result = cpp_read_pp_operator(file, lex.pos); + } + else{ + result = cpp_read_pp_default_mode(file, lex.pos, 1); + } + lex.pos = result.pos; + result.token.flags |= CPP_TFLAG_PP_BODY; + break; + + case CPP_LEX_PP_NUMBER: + if (!char_is_numeric(current)){ + has_result = 0; + lex.pp_state = CPP_LEX_PP_JUNK; + } + else{ + result = cpp_read_number(file, lex.pos); + lex.pos = result.pos; + result.token.flags |= CPP_TFLAG_PP_BODY; + lex.pp_state = CPP_LEX_PP_INCLUDE; + } + break; + + case CPP_LEX_PP_ERROR: + result = cpp_read_junk_line(file, lex.pos); + lex.pos = result.pos; + result.token.type = CPP_TOKEN_ERROR_MESSAGE; + result.token.flags |= CPP_TFLAG_PP_BODY; + break; + + default: + { + bool took_comment = 0; + if (current == '/' && lex.pos + 1 < file.size){ + if (file.data[lex.pos + 1] == '/'){ + result = cpp_read_line_comment(file, lex.pos); + lex.pp_state = CPP_LEX_PP_DEFAULT; + lex.pos = result.pos; + took_comment = 1; + }else if (file.data[lex.pos + 1] == '*'){ + result = cpp_read_block_comment(file, lex.pos); + lex.pos = result.pos; + took_comment = 1; + } + } + + if (!took_comment){ + result = cpp_read_junk_line(file, lex.pos); + lex.pos = result.pos; + result.token.flags |= CPP_TFLAG_PP_BODY; + } + }break; + + } + } + } + } + + result.token.state_flags = state_flags; + result.has_result = has_result; + + *lex_data = lex; + return result; +} + +FCPP_LINK int +cpp_lex_file_token_count(Cpp_File file){ + int count = 0; + Cpp_Lex_Data lex = {}; + Cpp_Token token = {}; + while (lex.pos < file.size){ + Cpp_Read_Result step_result = cpp_lex_step(file, &lex); + + if (step_result.has_result){ + if (count > 0){ + Cpp_Token_Merge merge = cpp_attempt_token_merge(token, step_result.token); + if (merge.did_merge){ + token = merge.new_token; + } + else{ + token = step_result.token; + ++count; + } + } + else{ + token = step_result.token; + ++count; + } + } + } + return count; +} + +FCPP_LINK Cpp_Lex_Data +cpp_lex_file_nonalloc(Cpp_File file, Cpp_Token_Stack *token_stack_out, Cpp_Lex_Data data){ + while (data.pos < file.size){ + Cpp_Lex_Data prev_lex = data; + Cpp_Read_Result step_result = cpp_lex_step(file, &data); + + if (step_result.has_result){ + if (!cpp_push_token_nonalloc(token_stack_out, step_result.token)){ + data = prev_lex; + return data; + } + } + } + + data.complete = 1; + return data; +} + +FCPP_LINK Cpp_Get_Token_Result +cpp_get_token(Cpp_Token_Stack *token_stack, int pos){ + int first, last; + first = 0; + last = token_stack->count; + + Cpp_Get_Token_Result result = {}; + if (token_stack->count > 0){ + for (;;){ + result.token_index = (first + last)/2; + + int this_start = token_stack->tokens[result.token_index].start; + int next_start; + if (result.token_index + 1 < token_stack->count){ + next_start = token_stack->tokens[result.token_index+1].start; + } + else{ + next_start = this_start + token_stack->tokens[result.token_index].size; + } + if (this_start <= pos && pos < next_start){ + break; + } + else if (pos < this_start){ + last = result.token_index; + } + else{ + first = result.token_index + 1; + } + if (first == last){ + result.token_index = first; + break; + } + } + + if (result.token_index == token_stack->count){ + --result.token_index; + result.in_whitespace = 1; + } + else{ + Cpp_Token *token = token_stack->tokens + result.token_index; + if (token->start + token->size <= pos){ + result.in_whitespace = 1; + } + } + } + else{ + result.token_index = -1; + result.in_whitespace = 1; + } + + return result; +} + +FCPP_LINK int +cpp_get_end_token(Cpp_Token_Stack *stack, int end){ + Cpp_Get_Token_Result result = cpp_get_token(stack, end); + if (result.token_index < 0) result.token_index = 0; + else if (end > stack->tokens[result.token_index].start) ++result.token_index; + return result.token_index; +} + +FCPP_LINK void +cpp_shift_token_starts(Cpp_Token_Stack *stack, int from_token_i, int amount){ + int count = stack->count; + Cpp_Token *token = stack->tokens + from_token_i; + for (int i = from_token_i; i < count; ++i, ++token){ + token->start += amount; + } +} + +FCPP_LINK Cpp_Relex_State +cpp_relex_nonalloc_start(Cpp_File file, Cpp_Token_Stack *stack, + int start, int end, int amount, int tolerance){ + Cpp_Relex_State state; + state.file = file; + state.stack = stack; + state.start = start; + state.end = end; + state.amount = amount; + state.tolerance = tolerance; + + Cpp_Get_Token_Result result = cpp_get_token(stack, start); + if (result.token_index <= 0){ + state.start_token_i = 0; + } + else{ + state.start_token_i = result.token_index-1; + } + + result = cpp_get_token(stack, end); + if (result.token_index < 0) result.token_index = 0; + else if (end > stack->tokens[result.token_index].start) ++result.token_index; + state.end_token_i = result.token_index; + + state.relex_start = stack->tokens[state.start_token_i].start; + if (start < state.relex_start) state.relex_start = start; + + state.space_request = state.end_token_i - state.start_token_i + tolerance + 1; + + return state; +} + +inline Cpp_Token +cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int size, int index){ + Cpp_Token result; + if (index < stack->count){ + result = tokens[index]; + } + else{ + result.start = size; + result.size = 0; + result.type = CPP_TOKEN_EOF; + result.flags = 0; + result.state_flags = 0; + } + return result; +} + +FCPP_LINK bool +cpp_relex_nonalloc_main(Cpp_Relex_State *state, Cpp_Token_Stack *relex_stack, int *relex_end){ + Cpp_Token_Stack *stack = state->stack; + Cpp_Token *tokens = stack->tokens; + + cpp_shift_token_starts(stack, state->end_token_i, state->amount); + + Cpp_Lex_Data lex = {}; + lex.pp_state = cpp_token_get_pp_state(tokens[state->start_token_i].state_flags); + lex.pos = state->relex_start; + + int relex_end_i = state->end_token_i; + Cpp_Token match_token = cpp__get_token(stack, tokens, state->file.size, relex_end_i); + Cpp_Token end_token = match_token; + bool went_too_far = 0; + + for (;;){ + Cpp_Read_Result read = cpp_lex_step(state->file, &lex); + if (read.has_result){ + if (read.token.start == end_token.start && + read.token.size == end_token.size && + read.token.flags == end_token.flags && + read.token.state_flags == end_token.state_flags){ + break; + } + cpp_push_token_nonalloc(relex_stack, read.token); + + while (lex.pos > end_token.start && relex_end_i < stack->count){ + ++relex_end_i; + end_token = cpp__get_token(stack, tokens, state->file.size, relex_end_i); + } + if (relex_stack->count == relex_stack->max_count){ + went_too_far = 1; + break; + } + } + if (lex.pos >= state->file.size) break; + } + + if (!went_too_far){ + if (relex_stack->count > 0){ + if (state->start_token_i > 0){ + Cpp_Token_Merge merge = + cpp_attempt_token_merge(tokens[state->start_token_i - 1], + relex_stack->tokens[0]); + if (merge.did_merge){ + --state->start_token_i; + relex_stack->tokens[0] = merge.new_token; + } + } + + if (relex_end_i < state->stack->count){ + Cpp_Token_Merge merge = + cpp_attempt_token_merge(relex_stack->tokens[relex_stack->count-1], + tokens[relex_end_i]); + if (merge.did_merge){ + ++relex_end_i; + relex_stack->tokens[relex_stack->count-1] = merge.new_token; + } + } + } + + *relex_end = relex_end_i; + } + else{ + cpp_shift_token_starts(stack, state->end_token_i, -state->amount); + } + + return went_too_far; +} + +#ifndef FCPP_FORBID_MALLOC +FCPP_LINK Cpp_Token_Stack +cpp_make_token_stack(int starting_max){ + Cpp_Token_Stack token_stack; + token_stack.count = 0; + token_stack.max_count = starting_max; + token_stack.tokens = (Cpp_Token*)FCPP_GET_MEMORY(sizeof(Cpp_Token)*starting_max); + return token_stack; +} + +FCPP_LINK void +cpp_free_token_stack(Cpp_Token_Stack token_stack){ + FCPP_FREE_MEMORY(token_stack.tokens); +} + +FCPP_LINK void +cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int new_max){ + Cpp_Token *new_tokens = (Cpp_Token*)FCPP_GET_MEMORY(sizeof(Cpp_Token)*new_max); + + if (new_tokens){ + FCPP_MEM_COPY(new_tokens, token_stack->tokens, sizeof(Cpp_Token)*token_stack->count); + FCPP_FREE_MEMORY(token_stack->tokens); + token_stack->tokens = new_tokens; + token_stack->max_count = new_max; + } +} + +FCPP_LINK void +cpp_push_token(Cpp_Token_Stack *token_stack, Cpp_Token token){ + if (!cpp_push_token_nonalloc(token_stack, token)){ + int new_max = 2*token_stack->max_count + 1; + cpp_resize_token_stack(token_stack, new_max); + bool result = cpp_push_token_nonalloc(token_stack, token); + _Assert(result); + } +} + +FCPP_LINK void +cpp_lex_file(Cpp_File file, Cpp_Token_Stack *token_stack_out){ + Cpp_Lex_Data lex = {}; + while (lex.pos < file.size){ + Cpp_Read_Result step_result = cpp_lex_step(file, &lex); + if (step_result.has_result){ + cpp_push_token(token_stack_out, step_result.token); + } + } +} + +FCPP_LINK bool +cpp_relex_file_limited(Cpp_File file, Cpp_Token_Stack *stack, + int start, int end, int amount, int tolerance){ +#if 0 + int start_token_i, end_token_i; + Cpp_Get_Token_Result get_result = cpp_get_token(token_stack, start_i); + start_token_i = get_result.token_index; + get_result = cpp_get_token(token_stack, end_i); + end_token_i = get_result.token_index; + if (end_token_i == -1){ + end_token_i = 0; + } + else if (end > token_stack->tokens[end_token_i].start){ + ++end_token_i; + } + cpp_shift_token_starts(token_stack, end_token_i, amount); + + int relex_start_i = start_token_i - 1; + if (relex_start_i < 0){ + relex_start_i = 0; + } + + int end_guess_i = end_token_i + 1; + if (end_guess_i > token_stack->count){ + --end_guess_i; + } +#endif + + int relex_start_i; + int end_token_i, end_guess_i; + { + Cpp_Get_Token_Result result = cpp_get_token(stack, start); + if (result.token_index <= 0){ + relex_start_i = 0; + } + else{ + relex_start_i = result.token_index-1; + } + + result = cpp_get_token(stack, end); + if (result.token_index < 0) result.token_index = 0; + else if (end > stack->tokens[result.token_index].start) ++result.token_index; + end_token_i = result.token_index; + end_guess_i = result.token_index+1; + } + + int relex_start = stack->tokens[relex_start_i].start; + if (start < relex_start) relex_start = start; + + cpp_shift_token_starts(stack, end_token_i, amount); + Cpp_Token_Stack relex_stack = cpp_make_token_stack((end_guess_i - relex_start_i + 1) * 3 / 2); + Cpp_Lex_Data lex = {}; + lex.pp_state = cpp_token_get_pp_state(stack->tokens[relex_start_i].state_flags); + lex.pos = relex_start; + bool went_too_far = 0; + + while (1){ + Cpp_Read_Result result = cpp_lex_step(file, &lex); + if (result.has_result){ + if (end_guess_i < stack->count && + result.token.start == stack->tokens[end_guess_i].start && + result.token.size == stack->tokens[end_guess_i].size && + result.token.flags == stack->tokens[end_guess_i].flags && + result.token.state_flags == stack->tokens[end_guess_i].state_flags){ + break; + } + else{ + cpp_push_token(&relex_stack, result.token); + while (lex.pos > stack->tokens[end_guess_i].start && + end_guess_i < stack->count){ + ++end_guess_i; + } + } + } + + if (lex.pos >= file.size){ + break; + } + + if (tolerance >= 0 && relex_stack.count + relex_start_i >= end_guess_i + tolerance){ + went_too_far = 1; + break; + } + } + + if (!went_too_far){ + int relex_end_i = end_guess_i; + + if (relex_stack.count > 0){ + if (relex_start_i > 0){ + Cpp_Token_Merge merge = cpp_attempt_token_merge(stack->tokens[relex_start_i - 1], + relex_stack.tokens[0]); + if (merge.did_merge){ + --relex_start_i; + relex_stack.tokens[0] = merge.new_token; + } + } + + if (relex_end_i < stack->count){ + Cpp_Token_Merge merge = cpp_attempt_token_merge(relex_stack.tokens[relex_stack.count - 1], + stack->tokens[relex_end_i]); + if (merge.did_merge){ + ++relex_end_i; + relex_stack.tokens[relex_stack.count - 1] = merge.new_token; + } + } + } + + int token_delete_amount = relex_end_i - relex_start_i; + int token_shift_amount = relex_stack.count - token_delete_amount; + + if (token_shift_amount != 0){ + int new_token_count = stack->count + token_shift_amount; + if (new_token_count > stack->max_count){ + int new_max = 2*stack->max_count + 1; + while (new_token_count > new_max){ + new_max = 2*new_max + 1; + } + cpp_resize_token_stack(stack, new_max); + } + + if (relex_end_i < stack->count){ + FCPP_MEM_MOVE(stack->tokens + relex_end_i + token_shift_amount, + stack->tokens + relex_end_i, sizeof(Cpp_Token)*(stack->count - relex_end_i)); + } + + stack->count += token_shift_amount; + } + + FCPP_MEM_COPY(stack->tokens + relex_start_i, relex_stack.tokens, sizeof(Cpp_Token)*relex_stack.count); + cpp_free_token_stack(relex_stack); + } + + else{ + cpp_shift_token_starts(stack, end_token_i, -amount); + cpp_free_token_stack(relex_stack); + } + + return went_too_far; +} +#endif + +#undef _Assert +#undef _TentativeAssert + +#undef FCPP_LEXER_IMPLEMENTATION +#endif // #ifdef FCPP_LEXER_IMPLEMENTATION + +// BOTTOM diff --git a/test_data/lots_of_files/4cpp_preprocessor.cpp b/test_data/lots_of_files/4cpp_preprocessor.cpp new file mode 100644 index 0000000..ce82589 --- /dev/null +++ b/test_data/lots_of_files/4cpp_preprocessor.cpp @@ -0,0 +1,19 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 30.11.2015 + * + * CPP preprocessor + * + */ + +// TOP + +#define byte unsigned char + + + +#undef byte + +// BOTTOM + diff --git a/test_data/lots_of_files/4cpp_types.h b/test_data/lots_of_files/4cpp_types.h new file mode 100644 index 0000000..0499d55 --- /dev/null +++ b/test_data/lots_of_files/4cpp_types.h @@ -0,0 +1,39 @@ +/* "4cpp" Open C++ Parser v0.1: Types + no warranty implied; use at your own risk + +NOTES ON USE: + This file is used to declare 4cpp fixed width integer and float types. + It is not meant to be used directly. +*/ + +// TODO(allen): +// - create non stdint.h version in case someone wants to exclude that header + +#include "4coder_config.h" + +#ifndef FCPP_TYPES +#define FCPP_TYPES + +#include <stdint.h> + +typedef uint8_t fcpp_u8; +typedef uint64_t fcpp_u64; +typedef uint32_t fcpp_u32; +typedef uint16_t fcpp_u16; + +typedef int8_t fcpp_i8; +typedef int64_t fcpp_i64; +typedef int32_t fcpp_i32; +typedef int16_t fcpp_i16; + +typedef fcpp_i32 fcpp_bool32; +typedef fcpp_i8 fcpp_bool8; + +typedef float fcpp_real32; +typedef double fcpp_real64; + +#define FCPP_GLOBAL static + +#define FCPP_COUNT(a) (sizeof(a)/sizeof(*(a))) + +#endif diff --git a/test_data/lots_of_files/4ed.cpp b/test_data/lots_of_files/4ed.cpp new file mode 100644 index 0000000..9b42d16 --- /dev/null +++ b/test_data/lots_of_files/4ed.cpp @@ -0,0 +1,4517 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.12.2014 + * + * Application layer for project codename "4ed" + * + */ + +// TOP + +// App Structs + +enum App_State{ + APP_STATE_EDIT, + APP_STATE_RESIZING, + // never below this + APP_STATE_COUNT +}; + +struct App_State_Resizing{ + Panel_Divider *divider; + i32 min, max; +}; + +struct CLI_Process{ + CLI_Handles cli; + Editing_File *out_file; +}; + +struct CLI_List{ + CLI_Process *procs; + i32 count, max; +}; + +#define SysAppCreateView 0x1 +#define SysAppCreateNewBuffer 0x2 + +struct Sys_App_Binding{ + i32 sys_id; + i32 app_id; + + u32 success; + u32 fail; + Panel *panel; +}; + +struct Complete_State{ + Search_Set set; + Search_Iter iter; + Table hits; + String_Space str; + i32 word_start, word_end; + b32 initialized; +}; + +struct Command_Data{ + Models *models; + struct App_Vars *vars; + System_Functions *system; + Exchange *exchange; + Live_Views *live_set; + + Panel *panel; + View *view; + + i32 screen_width, screen_height; + Key_Event_Data key; + + Partition part; +}; + +struct App_Vars{ + Models models; + + CLI_List cli_processes; + + Sys_App_Binding *sys_app_bindings; + i32 sys_app_count, sys_app_max; + + Live_Views live_set; + + App_State state; + App_State_Resizing resizing; + Complete_State complete_state; + + Command_Data command_data; +}; + +internal i32 +app_get_or_add_map_index(Models *models, i32 mapid){ + i32 result; + i32 user_map_count = models->user_map_count; + i32 *map_id_table = models->map_id_table; + for (result = 0; result < user_map_count; ++result){ + if (map_id_table[result] == mapid) break; + if (map_id_table[result] == 0){ + map_id_table[result] = mapid; + break; + } + } + return result; +} + +internal i32 +app_get_map_index(Models *models, i32 mapid){ + i32 result; + i32 user_map_count = models->user_map_count; + i32 *map_id_table = models->map_id_table; + for (result = 0; result < user_map_count; ++result){ + if (map_id_table[result] == mapid) break; + if (map_id_table[result] == 0){ + result = user_map_count; + break; + } + } + return result; +} + +internal Command_Map* +app_get_map(Models *models, i32 mapid){ + Command_Map *map = 0; + if (mapid < mapid_global) map = models->user_maps + mapid; + else if (mapid == mapid_global) map = &models->map_top; + else if (mapid == mapid_file) map = &models->map_file; + return map; +} + +// Commands + +globalvar Application_Links app_links; + +#define USE_MODELS(n) Models *n = command->models +#define USE_VARS(n) App_Vars *n = command->vars +#define USE_PANEL(n) Panel *n = command->panel +#define USE_VIEW(n) View *n = command->view +#define USE_FILE(n,v) Editing_File *n = (v)->file +#define USE_EXCHANGE(n) Exchange *n = command->exchange + +#define REQ_OPEN_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_Open) return +#define REQ_READABLE_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_NoWrite) return + +#define REQ_FILE(n,v) Editing_File *n = (v)->file; if (!n) return +#define REQ_FILE_HISTORY(n,v) Editing_File *n = (v)->file; if (!n || !n->state.undo.undo.edits) return + +#define COMMAND_DECL(n) internal void command_##n(System_Functions *system, Command_Data *command, Command_Binding binding) + +struct Command_Parameter{ + i32 type; + union{ + struct{ + Dynamic param; + Dynamic value; + } param; + struct{ + i32 len; + char *str; + } inline_string; + }; +}; + +inline Command_Parameter* +param_next(Command_Parameter *param, Command_Parameter *end){ + Command_Parameter *result = param; + if (result->type == 0){ + ++result; + } + while (result->type != 0 && result < end){ + i32 len = result->inline_string.len; + len += sizeof(*result) - 1; + len -= (len % sizeof(*result)); + result = (Command_Parameter*)((char*)result + len + sizeof(*result)); + } + return result; +} + +inline Command_Parameter* +param_stack_first(Partition *part, Command_Parameter *end){ + Command_Parameter *result = (Command_Parameter*)part->base; + if (result->type != 0) result = param_next(result, end); + return result; +} + +inline Command_Parameter* +param_stack_end(Partition *part){ + return (Command_Parameter*)((char*)part->base + part->pos); +} + +internal View* +panel_make_empty(System_Functions *system, Exchange *exchange, App_Vars *vars, Panel *panel){ + Models *models = &vars->models; + View_And_ID new_view; + + Assert(panel->view == 0); + new_view = live_set_alloc_view(&vars->live_set, panel, models); + view_set_file(new_view.view, 0, models, 0, 0, 0); + new_view.view->map = app_get_map(models, mapid_global); + + return(new_view.view); +} + +COMMAND_DECL(null){ + AllowLocal(command); +} + +COMMAND_DECL(write_character){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + char character; + i32 pos, next_cursor_pos; + + character = command->key.character; + if (character != 0){ + pos = view->cursor.pos; + next_cursor_pos = view->cursor.pos + 1; + view_replace_range(system, models, view, pos, pos, &character, 1, next_cursor_pos); + view_cursor_move(view, next_cursor_pos); + } +} + +COMMAND_DECL(seek_whitespace_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +internal i32 +seek_token_left(Cpp_Token_Stack *tokens, i32 pos){ + Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); + if (get.token_index == -1){ + get.token_index = 0; + } + + Cpp_Token *token = tokens->tokens + get.token_index; + if (token->start == pos && get.token_index > 0){ + --token; + } + + return token->start; +} + +internal i32 +seek_token_right(Cpp_Token_Stack *tokens, i32 pos){ + Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); + if (get.in_whitespace){ + ++get.token_index; + } + if (get.token_index >= tokens->count){ + get.token_index = tokens->count-1; + } + + Cpp_Token *token = tokens->tokens + get.token_index; + return token->start + token->size; +} + +COMMAND_DECL(seek_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + u32 flags = BoundryWhitespace; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_flags: + flags = dynamic_to_int(¶m->param.value); + break; + } + } + + i32 pos[4] = {0}; + + if (flags & (1)){ + pos[0] = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos); + } + + if (flags & (1 << 1)){ + if (file->state.tokens_complete){ + pos[1] = seek_token_left(&file->state.token_stack, view->cursor.pos); + } + else{ + pos[1] = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos); + } + } + + if (flags & (1 << 2)){ + pos[2] = buffer_seek_alphanumeric_left(&file->state.buffer, view->cursor.pos); + if (flags & (1 << 3)){ + pos[3] = buffer_seek_range_camel_left(&file->state.buffer, view->cursor.pos, pos[2]); + } + } + else{ + if (flags & (1 << 3)){ + pos[3] = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, view->cursor.pos); + } + } + + i32 new_pos = 0; + for (i32 i = 0; i < ArrayCount(pos); ++i){ + if (pos[i] > new_pos) new_pos = pos[i]; + } + + view_cursor_move(view, new_pos); +} + +COMMAND_DECL(seek_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + u32 flags = BoundryWhitespace; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_flags: + flags = dynamic_to_int(¶m->param.value); + break; + } + } + + i32 size = buffer_size(&file->state.buffer); + i32 pos[4]; + for (i32 i = 0; i < ArrayCount(pos); ++i) pos[i] = size; + + if (flags & (1)){ + pos[0] = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos); + } + + if (flags & (1 << 1)){ + if (file->state.tokens_complete){ + pos[1] = seek_token_right(&file->state.token_stack, view->cursor.pos); + } + else{ + pos[1] = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos); + } + } + + if (flags & (1 << 2)){ + pos[2] = buffer_seek_alphanumeric_right(&file->state.buffer, view->cursor.pos); + if (flags & (1 << 3)){ + pos[3] = buffer_seek_range_camel_right(&file->state.buffer, view->cursor.pos, pos[2]); + } + } + else{ + if (flags & (1 << 3)){ + pos[3] = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, view->cursor.pos); + } + } + + i32 new_pos = size; + for (i32 i = 0; i < ArrayCount(pos); ++i){ + if (pos[i] < new_pos) new_pos = pos[i]; + } + + view_cursor_move(view, new_pos); +} + +COMMAND_DECL(seek_whitespace_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_whitespace_up){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_whitespace_up(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_whitespace_down){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_whitespace_down(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_token_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + if (file->state.tokens_complete){ + i32 pos = seek_token_left(&file->state.token_stack, view->cursor.pos); + view_cursor_move(view, pos); + } +} + +COMMAND_DECL(seek_token_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + if (file->state.tokens_complete){ + i32 pos = seek_token_right(&file->state.token_stack, view->cursor.pos); + view_cursor_move(view, pos); + } +} + +COMMAND_DECL(seek_white_or_token_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 token_pos, white_pos; + if (file->state.tokens_complete){ + token_pos = seek_token_right(&file->state.token_stack, view->cursor.pos); + } + else{ + token_pos = buffer_size(&file->state.buffer); + } + white_pos = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, Min(token_pos, white_pos)); +} + +COMMAND_DECL(seek_white_or_token_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 token_pos, white_pos; + if (file->state.tokens_complete){ + token_pos = seek_token_left(&file->state.token_stack, view->cursor.pos); + } + else{ + token_pos = 0; + } + white_pos = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, Max(token_pos, white_pos)); +} + +COMMAND_DECL(seek_alphanumeric_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_alphanumeric_right(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_alphanumeric_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_alphanumeric_left(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_alphanumeric_or_camel_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_alphanumeric_or_camel_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(word_complete){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_VARS(vars); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + Partition *part = &models->mem.part; + General_Memory *general = &models->mem.general; + Working_Set *working_set = &models->working_set; + Complete_State *complete_state = &vars->complete_state; + Search_Range *ranges; + Search_Match match; + + Temp_Memory temp; + + Buffer_Type *buffer; + Buffer_Backify_Type loop; + char *data; + i32 end; + i32 size_of_buffer; + + i32 cursor_pos, word_start, word_end; + char c; + + char *spare; + i32 size; + + i32 match_size; + b32 do_init = 0; + + buffer = &file->state.buffer; + size_of_buffer = buffer_size(buffer); + + if (view->mode.rewrite != 2){ + do_init = 1; + } + view->next_mode.rewrite = 2; + + if (complete_state->initialized == 0){ + do_init = 1; + } + + if (do_init){ + word_end = view->cursor.pos; + word_start = word_end; + cursor_pos = word_end - 1; + + // TODO(allen): macros for these buffer loops and some method of breaking out of them. + for (loop = buffer_backify_loop(buffer, cursor_pos, 0); + buffer_backify_good(&loop); + buffer_backify_next(&loop)){ + end = loop.absolute_pos; + data = loop.data - loop.absolute_pos; + for (; cursor_pos >= end; --cursor_pos){ + c = data[cursor_pos]; + if (char_is_alpha(c)){ + word_start = cursor_pos; + } + else if (!char_is_numeric(c)){ + goto double_break; + } + } + } + double_break:; + + size = word_end - word_start; + + if (size == 0){ + complete_state->initialized = 0; + return; + } + + complete_state->initialized = 1; + search_iter_init(general, &complete_state->iter, size); + buffer_stringify(buffer, word_start, word_end, complete_state->iter.word.str); + complete_state->iter.word.size = size; + + { + File_Node *node, *used_nodes; + Editing_File *file_ptr; + i32 buffer_count, j; + + buffer_count = working_set->file_count; + search_set_init(general, &complete_state->set, buffer_count + 1); + ranges = complete_state->set.ranges; + ranges[0].buffer = buffer; + ranges[0].start = 0; + ranges[0].size = word_start; + + ranges[1].buffer = buffer; + ranges[1].start = word_end; + ranges[1].size = size_of_buffer - word_end; + + used_nodes = &working_set->used_sentinel; + j = 2; + for (dll_items(node, used_nodes)){ + file_ptr = (Editing_File*)node; + if (file_ptr != file){ + ranges[j].buffer = &file_ptr->state.buffer; + ranges[j].start = 0; + ranges[j].size = buffer_size(ranges[j].buffer); + ++j; + } + } + complete_state->set.count = j; + } + + search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4)); + search_hit_add(general, &complete_state->hits, &complete_state->str, + complete_state->iter.word.str, complete_state->iter.word.size); + + complete_state->word_start = word_start; + complete_state->word_end = word_end; + } + else{ + word_start = complete_state->word_start; + word_end = complete_state->word_end; + size = complete_state->iter.word.size; + } + + if (size > 0){ + for (;;){ + match = search_next_match(part, &complete_state->set, &complete_state->iter); + + if (match.found_match){ + temp = begin_temp_memory(part); + match_size = match.end - match.start; + spare = (char*)push_array(part, char, match_size); + buffer_stringify(match.buffer, match.start, match.end, spare); + + if (search_hit_add(general, &complete_state->hits, &complete_state->str, spare, match_size)){ + view_replace_range(system, models, view, word_start, word_end, spare, match_size, word_end); + + complete_state->word_end = word_start + match_size; + complete_state->set.ranges[1].start = word_start + match_size; + break; + } + end_temp_memory(temp); + } + else{ + complete_state->iter.pos = 0; + complete_state->iter.i = 0; + + search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4)); + search_hit_add(general, &complete_state->hits, &complete_state->str, + complete_state->iter.word.str, complete_state->iter.word.size); + + match_size = complete_state->iter.word.size; + view_replace_range(system, models, view, word_start, word_end, + complete_state->iter.word.str, match_size, word_end); + + complete_state->word_end = word_start + match_size; + complete_state->set.ranges[1].start = word_start + match_size; + break; + } + } + } +} + +COMMAND_DECL(set_mark){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + view->mark = (i32)view->cursor.pos; +} + +COMMAND_DECL(copy){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + // TODO(allen): deduplicate + int r_start = 0, r_end = 0; + int start_set = 0, end_set = 0; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_range_start: + start_set = 1; + r_start = dynamic_to_int(¶m->param.value); + break; + + case par_range_end: + end_set = 1; + r_end = dynamic_to_int(¶m->param.value); + break; + } + } + + Range range = make_range(view->cursor.pos, view->mark); + if (start_set) range.start = r_start; + if (end_set) range.end = r_end; + if (range.start < range.end){ + clipboard_copy(system, &models->mem.general, &models->working_set, range, file); + } +} + +COMMAND_DECL(cut){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + // TODO(allen): deduplicate + int r_start = 0, r_end = 0; + int start_set = 0, end_set = 0; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_range_start: + start_set = 1; + r_start = dynamic_to_int(¶m->param.value); + break; + + case par_range_end: + end_set = 1; + r_end = dynamic_to_int(¶m->param.value); + break; + } + } + + Range range = make_range(view->cursor.pos, view->mark); + if (start_set) range.start = r_start; + if (end_set) range.end = r_end; + if (range.start < range.end){ + i32 next_cursor_pos = range.start; + + clipboard_copy(system, &models->mem.general, &models->working_set, range, file); + view_replace_range(system, models, view, range.start, range.end, 0, 0, next_cursor_pos); + + view->mark = range.start; + view_cursor_move(view, next_cursor_pos); + } +} + +COMMAND_DECL(paste){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + View_Iter iter; + String *src; + i32 pos_left, next_cursor_pos; + + if (models->working_set.clipboard_size > 0){ + view->next_mode.rewrite = 1; + + src = working_set_clipboard_head(&models->working_set); + pos_left = view->cursor.pos; + + next_cursor_pos = pos_left+src->size; + view_replace_range(system, models, view, pos_left, pos_left, src->str, src->size, next_cursor_pos); + + view_cursor_move(view, next_cursor_pos); + view->mark = pos_left; + + for (iter = file_view_iter_init(&models->layout, file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + view_post_paste_effect(iter.view, 20, pos_left, src->size, models->style.main.paste_color); + } + } +} + +COMMAND_DECL(paste_next){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + View_Iter iter; + Range range; + String *src; + i32 next_cursor_pos; + + if (models->working_set.clipboard_size > 0 && view->mode.rewrite == 1){ + view->next_mode.rewrite = 1; + + range = make_range(view->mark, view->cursor.pos); + src = working_set_clipboard_roll_down(&models->working_set); + next_cursor_pos = range.start+src->size; + view_replace_range(system, + models, view, range.start, range.end, + src->str, src->size, next_cursor_pos); + + view_cursor_move(view, next_cursor_pos); + view->mark = range.start; + + for (iter = file_view_iter_init(&models->layout, file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + view_post_paste_effect(iter.view, 20, range.start, src->size, models->style.main.paste_color); + } + } + else{ + command_paste(system, command, binding); + } +} + +COMMAND_DECL(delete_range){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + Range range; + i32 next_cursor_pos; + + range = make_range(view->cursor.pos, view->mark); + if (range.start < range.end){ + next_cursor_pos = range.start; + view_replace_range(system, models, view, range.start, range.end, 0, 0, next_cursor_pos); + view_cursor_move(view, next_cursor_pos); + view->mark = range.start; + } +} + +COMMAND_DECL(timeline_scrub){ + ProfileMomentFunction(); + REQ_OPEN_VIEW(view); + REQ_FILE_HISTORY(file, view); + + view_set_widget(view, FWIDG_TIMELINES); + view->widget.timeline.undo_line = 1; + view->widget.timeline.history_line = 1; +} + +COMMAND_DECL(undo){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE_HISTORY(file, view); + + view_undo(system, models, view); +} + +COMMAND_DECL(redo){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE_HISTORY(file, view); + + view_redo(system, models, view); +} + +COMMAND_DECL(history_backward){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE_HISTORY(file, view); + + view_history_step(system, models, view, hist_backward); +} + +COMMAND_DECL(history_forward){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE_HISTORY(file, view); + + view_history_step(system, models, view, hist_backward); +} + +COMMAND_DECL(interactive_new){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_VIEW(view); + + view_show_interactive(system, view, &models->map_ui, + IAct_New, IInt_Sys_File_List, make_lit_string("New: ")); +} + +internal Sys_App_Binding* +app_push_file_binding(App_Vars *vars, int sys_id, int app_id){ + Sys_App_Binding *binding; + Assert(vars->sys_app_count < vars->sys_app_max); + binding = vars->sys_app_bindings + vars->sys_app_count++; + binding->sys_id = sys_id; + binding->app_id = app_id; + return(binding); +} + +struct App_Open_File_Result{ + Editing_File *file; + i32 sys_id; + i32 file_index; + b32 is_new; +}; + +COMMAND_DECL(interactive_open){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_PANEL(panel); + USE_VIEW(view); + + Delay *delay = &models->delay1; + + char *filename = 0; + int filename_len = 0; + int do_in_background = 0; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + if (param->param.param.type == dynamic_type_int){ + if (param->param.param.int_value == par_name && + param->param.value.type == dynamic_type_string){ + filename = param->param.value.str_value; + filename_len = param->param.value.str_len; + } + else if (param->param.param.int_value == par_do_in_background){ + do_in_background = dynamic_to_int(¶m->param.value); + } + } + } + + if (filename){ + String string = make_string(filename, filename_len); + if (do_in_background){ + delayed_open_background(delay, string); + } + else{ + // TODO(allen): Change the behavior of all delayed_open/background + // calls so that they still allocate the buffer right away. This way + // it's still possible to get at the buffer if so wished in the API. + // The switch for this view doesn't need to happen until the file is ready. + delayed_open(delay, string, panel); + } + } + else{ + view_show_interactive(system, view, &models->map_ui, + IAct_Open, IInt_Sys_File_List, make_lit_string("Open: ")); + } +} + +internal void +view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){ + System_Functions *system = cmd->system; + Models *models = cmd->models; + + Partition old_part; + Temp_Memory temp; + View *old_view; + Partition *part; + + old_view = cmd->view; + old_part = cmd->part; + + cmd->view = panel->view; + part = &models->mem.part; + temp = begin_temp_memory(part); + cmd->part = partition_sub_part(part, Kbytes(16)); + + view_set_file(panel->view, file, models, system, + models->hooks[hook_open_file], &app_links); + + cmd->part = old_part; + end_temp_memory(temp); + cmd->view = old_view; + + panel->view->map = app_get_map(models, file->settings.base_map_id); +} + +// TODO(allen): Improvements to reopen +// - Preserve existing token stack +// - Keep current version open and do some sort of diff to keep +// the cursor position correct +COMMAND_DECL(reopen){ + ProfileMomentFunction(); + USE_VARS(vars); + USE_MODELS(models); + USE_VIEW(view); + REQ_FILE(file, view); + USE_EXCHANGE(exchange); + + if (match(file->name.source_path, file->name.live_name)) return; + + i32 file_id = exchange_request_file(exchange, expand_str(file->name.source_path)); + i32 index = 0; + if (file_id){ + file_set_to_loading(file); + index = (i32)(file - models->working_set.files); + app_push_file_binding(vars, file_id, index); + + view_set_file(view, file, models, system, + models->hooks[hook_open_file], &app_links); + } + else{ + // TODO(allen): feedback message + } +} + +COMMAND_DECL(save){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_VIEW(view); + USE_FILE(file, view); + + Delay *delay = &models->delay1; + + char *filename = 0; + int filename_len = 0; + int buffer_id = -1; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int v = dynamic_to_int(¶m->param.param); + if (v == par_name && param->param.value.type == dynamic_type_string){ + filename = param->param.value.str_value; + filename_len = param->param.value.str_len; + } + else if (v == par_buffer_id && param->param.value.type == dynamic_type_int){ + buffer_id = dynamic_to_int(¶m->param.value); + } + } + + String name = {}; + if (filename){ + name = make_string(filename, filename_len); + } + else if (file){ + name = file->name.source_path; + } + + if (name.size != 0){ + if (buffer_id == -1){ + if (file){ + delayed_save(delay, name, file); + } + } + else{ + file = models->working_set.files + buffer_id; + + if (!file->state.is_dummy && file_is_ready(file)){ + delayed_save(delay, name, file); + } + else{ + delayed_save(delay, name); + } + } + } +} + +COMMAND_DECL(interactive_save_as){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_interactive(system, view, &models->map_ui, + IAct_Save_As, IInt_Sys_File_List, make_lit_string("Save As: ")); +} + +COMMAND_DECL(change_active_panel){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_PANEL(panel); + + panel = panel->next; + if (panel == &models->layout.used_sentinel){ + panel = panel->next; + } + models->layout.active_panel = (i32)(panel - models->layout.panels); +} + +COMMAND_DECL(interactive_switch_buffer){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_interactive(system, view, &models->map_ui, + IAct_Switch, IInt_Live_File_List, make_lit_string("Switch Buffer: ")); +} + +COMMAND_DECL(interactive_kill_buffer){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_interactive(system, view, &models->map_ui, + IAct_Kill, IInt_Live_File_List, make_lit_string("Kill Buffer: ")); +} + +COMMAND_DECL(kill_buffer){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_VIEW(view); + USE_FILE(file, view); + + Delay *delay = &models->delay1; + int buffer_id = 0; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int v = dynamic_to_int(¶m->param.param); + if (v == par_buffer_id && param->param.value.type == dynamic_type_int){ + buffer_id = dynamic_to_int(¶m->param.value); + } + } + + if (buffer_id != 0){ + file = working_set_get_file(&models->working_set, buffer_id, 1).file; + if (file){ + delayed_kill(delay, file); + } + } + else if (file){ + delayed_try_kill(delay, file, view->panel); + } +} + +COMMAND_DECL(toggle_line_wrap){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + Relative_Scrolling scrolling = view_get_relative_scrolling(view); + if (view->unwrapped_lines){ + view->unwrapped_lines = 0; + file->settings.unwrapped_lines = 0; + view->target_x = 0; + view->cursor = + view_compute_cursor_from_pos(view, view->cursor.pos); + view->preferred_x = view->cursor.wrapped_x; + } + else{ + view->unwrapped_lines = 1; + file->settings.unwrapped_lines = 1; + view->cursor = + view_compute_cursor_from_pos(view, view->cursor.pos); + view->preferred_x = view->cursor.unwrapped_x; + } + view_set_relative_scrolling(view, scrolling); +} + +COMMAND_DECL(toggle_show_whitespace){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + view->show_whitespace = !view->show_whitespace; +} + +COMMAND_DECL(toggle_tokens){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + if (file->settings.tokens_exist){ + file_kill_tokens(system, &models->mem.general, file); + } + else{ + file_first_lex_parallel(system, &models->mem.general, file); + } +#endif +} + +internal void +case_change_range(System_Functions *system, + Mem_Options *mem, View *view, Editing_File *file, + u8 a, u8 z, u8 char_delta){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + Range range = make_range(view->cursor.pos, view->mark); + if (range.start < range.end){ + Edit_Step step = {}; + step.type = ED_NORMAL; + step.edit.start = range.start; + step.edit.end = range.end; + step.edit.len = range.end - range.start; + + if (file->state.still_lexing) + system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); + + file_update_history_before_edit(mem, file, step, 0, hist_normal); + + u8 *data = (u8*)file->state.buffer.data; + for (i32 i = range.start; i < range.end; ++i){ + if (data[i] >= a && data[i] <= z){ + data[i] += char_delta; + } + } + + if (file->state.token_stack.tokens) + file_relex_parallel(system, mem, file, range.start, range.end, 0); + } +#endif +} + +COMMAND_DECL(to_uppercase){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + case_change_range(system, &models->mem, view, file, 'a', 'z', (u8)('A' - 'a')); +} + +COMMAND_DECL(to_lowercase){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + case_change_range(system, &models->mem, view, file, 'A', 'Z', (u8)('a' - 'A')); +} + +COMMAND_DECL(clean_all_lines){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + view_clean_whitespace(system, models, view); +} + +COMMAND_DECL(eol_dosify){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + file->settings.dos_write_mode = 1; + file->state.last_4ed_edit_time = system->time(); +} + +COMMAND_DECL(eol_nixify){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + file->settings.dos_write_mode = 0; + file->state.last_4ed_edit_time = system->time(); +} + +COMMAND_DECL(auto_tab_range){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + int r_start = 0, r_end = 0; + int start_set = 0, end_set = 0; + int clear_blank_lines = 1; + + // TODO(allen): deduplicate + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_range_start: + start_set = 1; + r_start = dynamic_to_int(¶m->param.value); + break; + + case par_range_end: + end_set = 1; + r_end = dynamic_to_int(¶m->param.value); + break; + + case par_clear_blank_lines: + clear_blank_lines = dynamic_to_bool(¶m->param.value); + break; + } + } + + if (file->state.token_stack.tokens && file->state.tokens_complete && !file->state.still_lexing){ + Range range = make_range(view->cursor.pos, view->mark); + if (start_set) range.start = r_start; + if (end_set) range.end = r_end; + view_auto_tab_tokens(system, models, view, range.start, range.end, clear_blank_lines); + } +} + +COMMAND_DECL(open_panel_vsplit){ + ProfileMomentFunction(); + USE_VARS(vars); + USE_MODELS(models); + USE_PANEL(panel); + USE_EXCHANGE(exchange); + + if (models->layout.panel_count < models->layout.panel_max_count){ + Split_Result split = layout_split_panel(&models->layout, panel, 1); + + Panel *panel1 = panel; + Panel *panel2 = split.panel; + + panel2->screen_region = panel1->screen_region; + + panel2->full.x0 = split.divider->pos; + panel2->full.x1 = panel1->full.x1; + panel1->full.x1 = split.divider->pos; + + panel_fix_internal_area(panel1); + panel_fix_internal_area(panel2); + panel2->prev_inner = panel2->inner; + + models->layout.active_panel = (i32)(panel2 - models->layout.panels); + panel_make_empty(system, exchange, vars, panel2); + } +} + +COMMAND_DECL(open_panel_hsplit){ + ProfileMomentFunction(); + USE_VARS(vars); + USE_MODELS(models); + USE_PANEL(panel); + USE_EXCHANGE(exchange); + + if (models->layout.panel_count < models->layout.panel_max_count){ + Split_Result split = layout_split_panel(&models->layout, panel, 0); + + Panel *panel1 = panel; + Panel *panel2 = split.panel; + + panel2->screen_region = panel1->screen_region; + + panel2->full.y0 = split.divider->pos; + panel2->full.y1 = panel1->full.y1; + panel1->full.y1 = split.divider->pos; + + panel_fix_internal_area(panel1); + panel_fix_internal_area(panel2); + panel2->prev_inner = panel2->inner; + + models->layout.active_panel = (i32)(panel2 - models->layout.panels); + panel_make_empty(system, exchange, vars, panel2); + } +} + +COMMAND_DECL(close_panel){ + ProfileMomentFunction(); + USE_MODELS(models); + USE_PANEL(panel); + USE_VIEW(view); + USE_EXCHANGE(exchange); + + Panel *panel_ptr, *used_panels; + Divider_And_ID div, parent_div, child_div; + i32 child; + i32 parent; + i32 which_child; + i32 active; + + if (models->layout.panel_count > 1){ + live_set_free_view(system, exchange, command->live_set, view); + panel->view = 0; + + div = layout_get_divider(&models->layout, panel->parent); + + // This divider cannot have two child dividers. + Assert(div.divider->child1 == -1 || div.divider->child2 == -1); + + // Get the child who needs to fill in this node's spot + child = div.divider->child1; + if (child == -1) child = div.divider->child2; + + parent = div.divider->parent; + which_child = div.divider->which_child; + + // Fill the child in the slot this node use to hold + if (parent == -1){ + Assert(models->layout.root == div.id); + models->layout.root = child; + } + else{ + parent_div = layout_get_divider(&models->layout, parent); + if (which_child == -1){ + parent_div.divider->child1 = child; + } + else{ + parent_div.divider->child2 = child; + } + } + + // If there was a child divider, give it information about it's new parent. + if (child != -1){ + child_div = layout_get_divider(&models->layout, child); + child_div.divider->parent = parent; + child_div.divider->which_child = div.divider->which_child; + } + + // What is the new active panel? + active = -1; + if (child == -1){ + used_panels = &models->layout.used_sentinel; + for (dll_items(panel_ptr, used_panels)){ + if (panel_ptr != panel && panel_ptr->parent == div.id){ + panel_ptr->parent = parent; + panel_ptr->which_child = which_child; + active = (i32)(panel_ptr - models->layout.panels); + break; + } + } + } + else{ + panel_ptr = panel->next; + if (panel_ptr == &models->layout.used_sentinel) panel_ptr = panel_ptr->next; + Assert(panel_ptr != panel); + active = (i32)(panel_ptr - models->layout.panels); + } + + Assert(active != -1 && panel != models->layout.panels + active); + models->layout.active_panel = active; + + layout_free_divider(&models->layout, div.divider); + layout_free_panel(&models->layout, panel); + layout_fix_all_panels(&models->layout); + } +} + +COMMAND_DECL(move_left){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = view->cursor.pos; + if (pos > 0) --pos; + view_cursor_move(view, pos); +} + +COMMAND_DECL(move_right){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 size = buffer_size(&file->state.buffer); + i32 pos = view->cursor.pos; + if (pos < size) ++pos; + view_cursor_move(view, pos); +} + +COMMAND_DECL(delete){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + i32 size = buffer_size(&file->state.buffer); + i32 cursor_pos = view->cursor.pos; + if (0 < size && cursor_pos < size){ + i32 start, end; + start = cursor_pos; + end = cursor_pos+1; + + Assert(end - start > 0); + + i32 next_cursor_pos = start; + view_replace_range(system, models, view, start, end, 0, 0, next_cursor_pos); + view_cursor_move(view, next_cursor_pos); + } +} + +COMMAND_DECL(backspace){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_OPEN_VIEW(view); + REQ_FILE(file, view); + + i32 size = buffer_size(&file->state.buffer); + i32 cursor_pos = view->cursor.pos; + if (cursor_pos > 0 && cursor_pos <= size){ + i32 start, end; + end = cursor_pos; + start = cursor_pos-1; + + i32 shift = (end - start); + Assert(shift > 0); + + i32 next_cursor_pos = view->cursor.pos - shift; + view_replace_range(system, models, view, start, end, 0, 0, next_cursor_pos); + view_cursor_move(view, next_cursor_pos); + } +} + +COMMAND_DECL(move_up){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + f32 font_height = (f32)get_font_info(models->font_set, models->global_font.font_id)->height; + f32 cy = view_get_cursor_y(view)-font_height; + f32 px = view->preferred_x; + if (cy >= 0){ + view->cursor = view_compute_cursor_from_xy(view, px, cy); + file->state.cursor_pos = view->cursor.pos; + } +} + +COMMAND_DECL(move_down){ + ProfileMomentFunction(); + USE_MODELS(models); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + f32 font_height = (f32)get_font_info(models->font_set, models->global_font.font_id)->height; + f32 cy = view_get_cursor_y(view)+font_height; + f32 px = view->preferred_x; + view->cursor = view_compute_cursor_from_xy(view, px, cy); + file->state.cursor_pos = view->cursor.pos; +} + +COMMAND_DECL(seek_end_of_line){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = view_find_end_of_line(view, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(seek_beginning_of_line){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + + i32 pos = view_find_beginning_of_line(view, view->cursor.pos); + view_cursor_move(view, pos); +} + +COMMAND_DECL(page_down){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + + f32 height = view_compute_height(view); + f32 max_target_y = view_compute_max_target_y(view); + + view->target_y += height; + if (view->target_y > max_target_y) view->target_y = max_target_y; + + view->cursor = view_compute_cursor_from_xy( + view, 0, view->target_y + (height - view->font_height)*.5f); +} + +COMMAND_DECL(page_up){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + + f32 height = view_compute_height(view); + + view->target_y -= height; + if (view->target_y < 0) view->target_y = 0; + + view->cursor = view_compute_cursor_from_xy( + view, 0, view->target_y + (height - view->font_height)*.5f); +} + +COMMAND_DECL(open_color_tweaker){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_theme(view, &models->map_ui); +} + +COMMAND_DECL(open_config){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_config(view, &models->map_ui); +} + +COMMAND_DECL(open_menu){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + view_show_menu(view, &models->map_ui); +} + +COMMAND_DECL(close_minor_view){ + ProfileMomentFunction(); + USE_VIEW(view); + USE_MODELS(models); + + Command_Map *map = &models->map_top; + if (view->file){ + map = app_get_map(models, view->file->settings.base_map_id); + } + view_show_file(view, map); +} + +COMMAND_DECL(cursor_mark_swap){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + + i32 pos = view->cursor.pos; + view_cursor_move(view, view->mark); + view->mark = pos; +} + +COMMAND_DECL(user_callback){ + ProfileMomentFunction(); + if (binding.custom) binding.custom(&app_links); +} + +COMMAND_DECL(set_settings){ + ProfileMomentFunction(); + REQ_READABLE_VIEW(view); + REQ_FILE(file, view); + USE_MODELS(models); + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_lex_as_cpp_file: + { +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + int v = dynamic_to_bool(¶m->param.value); + if (file->settings.tokens_exist){ + if (!v) file_kill_tokens(system, &models->mem.general, file); + } + else{ + if (v) file_first_lex_parallel(system, &models->mem.general, file); + } +#endif + }break; + + case par_wrap_lines: + { + int v = dynamic_to_bool(¶m->param.value); + if (view->unwrapped_lines){ + if (v){ + view->unwrapped_lines = 0; + file->settings.unwrapped_lines = 0; + + if (!file->state.is_loading){ + Relative_Scrolling scrolling = view_get_relative_scrolling(view); + view->target_x = 0; + view->cursor = + view_compute_cursor_from_pos(view, view->cursor.pos); + view_set_relative_scrolling(view, scrolling); + } + } + } + else{ + if (!v){ + view->unwrapped_lines = 1; + file->settings.unwrapped_lines = 1; + + if (!file->state.is_loading){ + Relative_Scrolling scrolling = view_get_relative_scrolling(view); + view->cursor = + view_compute_cursor_from_pos(view, view->cursor.pos); + view_set_relative_scrolling(view, scrolling); + } + } + } + }break; + + case par_key_mapid: + { + int v = dynamic_to_int(¶m->param.value); + if (v == mapid_global) file->settings.base_map_id = mapid_global; + else if (v == mapid_file) file->settings.base_map_id = mapid_file; + else if (v < mapid_global){ + int index = app_get_map_index(models, v); + if (index < models->user_map_count) file->settings.base_map_id = v; + else file->settings.base_map_id = mapid_file; + } + }break; + } + } +} + +COMMAND_DECL(command_line){ + ProfileMomentFunction(); + USE_VARS(vars); + USE_MODELS(models); + USE_PANEL(panel); + USE_VIEW(view); + + Partition *part = &models->mem.part; + + char *buffer_name = 0; + char *path = 0; + char *script = 0; + + i32 buffer_id = 0; + i32 buffer_name_len = 0; + i32 path_len = 0; + i32 script_len = 0; + u32 flags = CLI_OverlapWithConflict; + b32 do_in_background = 0; + + Command_Parameter *end = param_stack_end(&command->part); + Command_Parameter *param = param_stack_first(&command->part, end); + for (; param < end; param = param_next(param, end)){ + int p = dynamic_to_int(¶m->param.param); + switch (p){ + case par_name: + { + char *new_buffer_name = dynamic_to_string(¶m->param.value, &buffer_name_len); + if (new_buffer_name){ + buffer_name = new_buffer_name; + } + }break; + + case par_buffer_id: + { + buffer_id = dynamic_to_int(¶m->param.value); + }break; + + case par_do_in_background: + { + do_in_background = 1; + }break; + + case par_cli_path: + { + char *new_cli_path = dynamic_to_string(¶m->param.value, &path_len); + if (new_cli_path){ + path = new_cli_path; + } + }break; + + case par_cli_command: + { + char *new_command = dynamic_to_string(¶m->param.value, &script_len); + if (new_command){ + script = new_command; + } + }break; + + case par_flags: + { + flags = (u32)dynamic_to_int(¶m->param.value); + }break; + } + } + + { + Working_Set *working_set = &models->working_set; + CLI_Process *procs = vars->cli_processes.procs, *proc = 0; + Get_File_Result file = {}; + b32 bind_to_new_view = !do_in_background; + + if (vars->cli_processes.count < vars->cli_processes.max){ + if (buffer_id){ + file = working_set_get_file(working_set, buffer_id, 1); + } + else if (buffer_name){ + file.file = working_set_contains(working_set, make_string(buffer_name, buffer_name_len)); + file.index = (i32)(file.file - working_set->files); + if (file.file == 0){ + file = working_set_get_available_file(working_set); + if (file.file == 0){ + // TODO(allen): feedback message - no available file + return; + } + } + } + + if (file.file){ + i32 proc_count = vars->cli_processes.count; + View_Iter iter; + i32 i; + + file_create_read_only(system, models, file.file, buffer_name); + file.file->settings.unimportant = 1; + table_add(&working_set->table, file.file->name.source_path, file.index); + + for (i = 0; i < proc_count; ++i){ + if (procs[i].out_file == file.file){ + if (flags & CLI_OverlapWithConflict) + procs[i].out_file = 0; + else + file.file = 0; + break; + } + } + + if (file.file){ + if (!(flags & CLI_AlwaysBindToView)){ + iter = file_view_iter_init(&models->layout, file.file, 0); + if (file_view_iter_good(iter)){ + bind_to_new_view = 0; + } + } + } + else{ + // TODO(allen): feedback message - file conflict + return; + } + } + + if (!path){ + path = models->hot_directory.string.str; + terminate_with_null(&models->hot_directory.string); + } + + { + Temp_Memory temp; + Range range; + Editing_File *view_file; + i32 size; + + temp = begin_temp_memory(part); + if (!script){ + view_file = view->file; + if (view_file){ + range = make_range(view->cursor.pos, view->mark); + size = range.end - range.start; + script = push_array(part, char, size + 1); + buffer_stringify(&view_file->state.buffer, range.start, range.end, script); + script[size] = 0; + } + else{ + script = " echo no script specified"; + } + } + + if (bind_to_new_view){ + view_file_in_panel(command, panel, file.file); + } + + proc = procs + vars->cli_processes.count++; + proc->out_file = file.file; + + if (!system->cli_call(path, script, &proc->cli)){ + --vars->cli_processes.count; + } + end_temp_memory(temp); + } + } + else{ + // TODO(allen): feedback message - no available process slot + return; + } + } +} + +internal void +update_command_data(App_Vars *vars, Command_Data *cmd){ + cmd->panel = cmd->models->layout.panels + cmd->models->layout.active_panel; + cmd->view = cmd->panel->view; +} + +globalvar Command_Function command_table[cmdid_count]; + +internal void +fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){ + *buffer = {}; + if (!file->state.is_dummy){ + buffer->exists = 1; + buffer->ready = file_is_ready(file); + + buffer->is_lexed = file->settings.tokens_exist; + buffer->buffer_id = (int)(file - working_set->files); + buffer->size = file->state.buffer.size; + buffer->buffer_cursor_pos = file->state.cursor_pos; + + buffer->file_name_len = file->name.source_path.size; + buffer->buffer_name_len = file->name.live_name.size; + buffer->file_name = file->name.source_path.str; + buffer->buffer_name = file->name.live_name.str; + + buffer->map_id = file->settings.base_map_id; + } +} + +internal void +fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){ + i32 lock_level; + int buffer_id; + *view = {}; + + if (vptr->in_use){ + view->exists = 1; + view->view_id = (int)(vptr - live_set->views) + 1; + view->line_height = vptr->font_height; + view->unwrapped_lines = vptr->unwrapped_lines; + + if (vptr->file){ + lock_level = view_lock_level(vptr); + buffer_id = (int)(vptr->file - working_set->files); + + if (lock_level <= 0){ + view->buffer_id = buffer_id; + } + else{ + view->buffer_id = 0; + } + + if (lock_level <= 1){ + view->locked_buffer_id = buffer_id; + } + else{ + view->locked_buffer_id = 0; + } + + if (lock_level <= 2){ + view->hidden_buffer_id = buffer_id; + } + else{ + view->hidden_buffer_id = 0; + } + + view->mark = view_compute_cursor_from_pos(vptr, vptr->mark); + view->cursor = vptr->cursor; + view->preferred_x = vptr->preferred_x; + } + } +} + +extern "C"{ + EXECUTE_COMMAND_SIG(external_exec_command_keep_stack){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Command_Function function = command_table[command_id]; + Command_Binding binding = {}; + binding.function = function; + if (function) function(cmd->system, cmd, binding); + + update_command_data(cmd->vars, cmd); + } + + PUSH_PARAMETER_SIG(external_push_parameter){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Partition *part = &cmd->part; + Command_Parameter *cmd_param = push_struct(part, Command_Parameter); + cmd_param->type = 0; + cmd_param->param.param = param; + cmd_param->param.value = value; + } + + PUSH_MEMORY_SIG(external_push_memory){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Partition *part = &cmd->part; + Command_Parameter *base = push_struct(part, Command_Parameter); + char *result = push_array(part, char, len); + int full_len = len + sizeof(Command_Parameter) - 1; + full_len -= (full_len % sizeof(Command_Parameter)); + part->pos += full_len - len; + base->type = 1; + base->inline_string.str = result; + base->inline_string.len = len; + return(result); + } + + CLEAR_PARAMETERS_SIG(external_clear_parameters){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + cmd->part.pos = 0; + } + + DIRECTORY_GET_HOT_SIG(external_directory_get_hot){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Hot_Directory *hot = &cmd->models->hot_directory; + i32 copy_max = capacity - 1; + hot_directory_clean_end(hot); + if (copy_max > hot->string.size) + copy_max = hot->string.size; + memcpy(out, hot->string.str, copy_max); + out[copy_max] = 0; + return(hot->string.size); + } + + GET_FILE_LIST_SIG(external_get_file_list){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + System_Functions *system = cmd->system; + File_List result = {}; + system->set_file_list(&result, make_string(dir, len)); + return(result); + } + + FREE_FILE_LIST_SIG(external_free_file_list){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + System_Functions *system = cmd->system; + system->set_file_list(&list, make_string(0, 0)); + } + + GET_BUFFER_FIRST_SIG(external_get_buffer_first){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Working_Set *working_set = &cmd->models->working_set; + Buffer_Summary result = {}; + if (working_set->file_count > 0){ + fill_buffer_summary(&result, (Editing_File*)working_set->used_sentinel.next, working_set); + } + return(result); + } + + GET_BUFFER_NEXT_SIG(external_get_buffer_next){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Working_Set *working_set = &cmd->models->working_set; + Editing_File *file; + + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file){ + file = (Editing_File*)file->node.next; + fill_buffer_summary(buffer, file, working_set); + } + else{ + *buffer = {}; + } + } + + GET_BUFFER_SIG(external_get_buffer){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Working_Set *working_set = &cmd->models->working_set; + Buffer_Summary buffer = {}; + Get_File_Result file; + + file = working_set_get_file(working_set, index, 1); + if (file.file){ + fill_buffer_summary(&buffer, file.file, working_set); + } + + return(buffer); + } + + GET_ACTIVE_BUFFER_SIG(external_get_active_buffer){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Buffer_Summary buffer = {}; + View *view = cmd->view; + Editing_File *file; + + if (view_lock_level(view) <= LockLevel_Open){ + file = view->file; + if (file){ + fill_buffer_summary(&buffer, file, &cmd->models->working_set); + } + } + + return(buffer); + } + + GET_PARAMETER_BUFFER_SIG(external_get_parameter_buffer){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Models *models = cmd->models; + Buffer_Summary buffer = {}; + + if (param_index >= 0 && param_index < models->buffer_param_count){ + buffer = external_get_buffer(app, models->buffer_param_indices[param_index]); + } + + return(buffer); + } + + GET_BUFFER_BY_NAME(external_get_buffer_by_name){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Buffer_Summary buffer = {}; + Editing_File *file; + Working_Set *working_set; + i32 index; + + working_set = &cmd->models->working_set; + if (table_find(&working_set->table, make_string(filename, len), &index)){ + file = working_set_get_file(working_set, index, 1).file; + if (file){ + fill_buffer_summary(&buffer, file, working_set); + } + } + + return(buffer); + } + + BUFFER_SEEK_DELIMITER_SIG(external_buffer_seek_delimiter){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_File *file; + Working_Set *working_set; + int result = 0; + int size; + + if (buffer->exists){ + working_set = &cmd->models->working_set; + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file && file_is_ready(file)){ + size = buffer_size(&file->state.buffer); + result = 1; + + if (start < 0 && !seek_forward) *out = start; + else if (start >= size && seek_forward) *out = start; + else{ + if (seek_forward){ + *out = buffer_seek_delimiter(&file->state.buffer, start, delim); + } + else{ + *out = buffer_reverse_seek_delimiter(&file->state.buffer, start, delim); + } + } + + fill_buffer_summary(buffer, file, working_set); + } + } + + return(result); + } + + BUFFER_SEEK_STRING_SIG(external_buffer_seek_string){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Models *models; + Editing_File *file; + Working_Set *working_set; + Partition *part; + Temp_Memory temp; + char *spare; + int result = 0; + int size; + + if (buffer->exists){ + models = cmd->models; + working_set = &models->working_set; + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file && file_is_ready(file)){ + size = buffer_size(&file->state.buffer); + + if (start < 0 && !seek_forward) *out = start; + else if (start >= size && seek_forward) *out = start; + else{ + part = &models->mem.part; + temp = begin_temp_memory(part); + spare = push_array(part, char, len); + result = 1; + if (seek_forward){ + *out = buffer_find_string(&file->state.buffer, start, size, str, len, spare); + } + else{ + *out = buffer_rfind_string(&file->state.buffer, start, str, len, spare); + } + end_temp_memory(temp); + } + fill_buffer_summary(buffer, file, working_set); + } + } + + return(result); + } + + REFRESH_BUFFER_SIG(external_refresh_buffer){ + int result; + *buffer = external_get_buffer(app, buffer->buffer_id); + result = buffer->exists; + return(result); + } + + BUFFER_READ_RANGE_SIG(external_buffer_read_range){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_File *file; + Working_Set *working_set; + int result = 0; + int size; + + if (buffer->exists){ + working_set = &cmd->models->working_set; + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file && file_is_ready(file)){ + size = buffer_size(&file->state.buffer); + if (0 <= start && start <= end && end <= size){ + result = 1; + buffer_stringify(&file->state.buffer, start, end, out); + } + fill_buffer_summary(buffer, file, working_set); + } + } + + return(result); + } + + BUFFER_REPLACE_RANGE_SIG(external_buffer_replace_range){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_File *file; + Working_Set *working_set; + + Models *models; + + int result = 0; + int size; + int next_cursor, pos; + + if (buffer->exists){ + models = cmd->models; + working_set = &models->working_set; + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file && file_is_ready(file)){ + size = buffer_size(&file->state.buffer); + if (0 <= start && start <= end && end <= size){ + result = 1; + + pos = file->state.cursor_pos; + if (pos < start) next_cursor = pos; + else if (pos < end) next_cursor = start; + else next_cursor = pos + end - start - len; + + file_replace_range(cmd->system, models, file, start, end, str, len, next_cursor); + } + fill_buffer_summary(buffer, file, working_set); + } + } + + return(result); + } + + BUFFER_SET_POS_SIG(external_buffer_set_pos){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_File *file; + Working_Set *working_set; + + int result = 0; + int size; + + if (buffer->exists){ + working_set = &cmd->models->working_set; + file = working_set_get_file(working_set, buffer->buffer_id, 1).file; + if (file && file_is_ready(file)){ + result = 1; + size = buffer_size(&file->state.buffer); + if (pos < 0) pos = 0; + if (pos > size) pos = size; + file->state.cursor_pos = pos; + fill_buffer_summary(buffer, file, working_set); + } + } + + return(result); + } + + GET_VIEW_FIRST_SIG(external_get_view_first){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_Layout *layout = &cmd->models->layout; + View_Summary view = {}; + + Panel *panel = layout->used_sentinel.next; + + Assert(panel != &layout->used_sentinel); + fill_view_summary(&view, panel->view, &cmd->vars->live_set, &cmd->models->working_set); + + return(view); + } + + GET_VIEW_NEXT_SIG(external_get_view_next){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Editing_Layout *layout = &cmd->models->layout; + Live_Views *live_set = &cmd->vars->live_set; + View *vptr; + Panel *panel; + int index = view->view_id - 1; + + if (index >= 0 && index < live_set->max){ + vptr = live_set->views + index; + panel = vptr->panel; + if (panel) panel = panel->next; + if (panel && panel != &layout->used_sentinel){ + fill_view_summary(view, panel->view, &cmd->vars->live_set, &cmd->models->working_set); + } + else{ + *view = {}; + } + } + else{ + *view = {}; + } + } + + GET_VIEW_SIG(external_get_view){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + View_Summary view = {}; + Live_Views *live_set = cmd->live_set; + int max = live_set->max; + View *vptr; + + index -= 1; + if (index >= 0 && index < max){ + vptr = live_set->views + index; + fill_view_summary(&view, vptr, live_set, &cmd->models->working_set); + } + + return(view); + } + + GET_ACTIVE_VIEW_SIG(external_get_active_view){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + View_Summary view = {}; + + fill_view_summary(&view, cmd->view, &cmd->vars->live_set, &cmd->models->working_set); + + return(view); + } + + REFRESH_VIEW_SIG(external_refresh_view){ + int result; + *view = external_get_view(app, view->view_id); + result = view->exists; + return(result); + } + + VIEW_SET_CURSOR_SIG(external_view_set_cursor){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Live_Views *live_set; + View *vptr; + int result = 0; + int view_id; + + if (view->exists){ + live_set = cmd->live_set; + view_id = view->view_id - 1; + if (view_id >= 0 && view_id < live_set->max){ + vptr = live_set->views + view_id; + result = 1; + if (seek.type == buffer_seek_line_char && seek.character <= 0){ + seek.character = 1; + } + vptr->cursor = view_compute_cursor(vptr, seek); + if (set_preferred_x){ + vptr->preferred_x = view_get_cursor_x(vptr); + } + fill_view_summary(view, vptr, live_set, &cmd->models->working_set); + } + } + + return(result); + } + + VIEW_SET_MARK_SIG(external_view_set_mark){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Live_Views *live_set; + View *vptr; + Full_Cursor cursor; + int result = 0; + int view_id; + + if (view->exists){ + live_set = cmd->live_set; + view_id = view->view_id - 1; + if (view_id >= 0 && view_id < live_set->max){ + vptr = live_set->views + view_id; + result = 1; + if (seek.type != buffer_seek_pos){ + cursor = view_compute_cursor(vptr, seek); + vptr->mark = cursor.pos; + } + else{ + vptr->mark = seek.pos; + } + fill_view_summary(view, vptr, live_set, &cmd->models->working_set); + } + } + + return(result); + } + + VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Live_Views *live_set; + View *vptr; + int result = 0; + int view_id; + + if (view->exists){ + live_set = cmd->live_set; + view_id = view->view_id - 1; + if (view_id >= 0 && view_id < live_set->max){ + vptr = live_set->views + view_id; + result = 1; + if (turn_on){ + view_set_temp_highlight(vptr, start, end); + } + else{ + vptr->show_temp_highlight = 0; + } + fill_view_summary(view, vptr, live_set, &cmd->models->working_set); + } + } + + return(result); + } + + VIEW_SET_BUFFER_SIG(external_view_set_buffer){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Live_Views *live_set; + View *vptr; + Get_File_Result file; + Working_Set *working_set; + Models *models; + int result = 0; + int view_id; + + if (view->exists){ + models = cmd->models; + live_set = cmd->live_set; + view_id = view->view_id - 1; + if (view_id >= 0 && view_id < live_set->max){ + vptr = live_set->views + view_id; + working_set = &models->working_set; + file = working_set_get_file(working_set, buffer_id, 1); + + if (file.file){ + result = 1; + if (file.file != vptr->file){ + view_set_file(vptr, file.file, models, + cmd->system, models->hooks[hook_open_file], &app_links); + } + } + + fill_view_summary(view, vptr, live_set, working_set); + } + } + + return(result); + } + + GET_USER_INPUT_SIG(external_get_user_input){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + System_Functions *system = cmd->system; + Coroutine *coroutine = cmd->models->command_coroutine; + User_Input result; + + Assert(coroutine); + *((u32*)coroutine->out+0) = get_type; + *((u32*)coroutine->out+1) = abort_type; + system->yield_coroutine(coroutine); + result = *(User_Input*)coroutine->in; + + return(result); + } + + START_QUERY_BAR_SIG(external_start_query_bar){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Query_Slot *slot = 0; + View *vptr; + + vptr = cmd->view; + + slot = alloc_query_slot(&vptr->query_set); + slot->query_bar = bar; + + return(slot != 0); + } + + END_QUERY_BAR_SIG(external_end_query_bar){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + View *vptr; + + vptr = cmd->view; + free_query_slot(&vptr->query_set, bar); + } + + CHANGE_THEME_SIG(external_change_theme){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Style_Library *styles = &cmd->models->styles; + String theme_name = make_string(name, len); + Style *s; + i32 i, count; + + count = styles->count; + s = styles->styles; + for (i = 0; i < count; ++i, ++s){ + if (match(s->name, theme_name)){ + style_copy(&cmd->models->style, s); + break; + } + } + } + + CHANGE_FONT_SIG(external_change_font){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Font_Set *set = cmd->models->font_set; + Style_Font *global_font = &cmd->models->global_font; + String font_name = make_string(name, len); + i16 font_id; + + if (font_set_extract(set, font_name, &font_id)){ + global_font->font_id = font_id; + global_font->font_changed = 1; + } + } + + SET_THEME_COLORS_SIG(external_set_theme_colors){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Style *style = &cmd->models->style; + Theme_Color *theme_color; + u32 *color; + i32 i; + + theme_color = colors; + for (i = 0; i < count; ++i, ++theme_color){ + color = style_index_by_tag(&style->main, theme_color->tag); + if (color) *color = theme_color->color | 0xFF000000; + } + } +} + +struct Command_In{ + Command_Data *cmd; + Command_Binding bind; +}; + +internal void +command_caller(Coroutine *coroutine){ + Command_In *cmd_in = (Command_In*)coroutine->in; + Command_Data *cmd = cmd_in->cmd; + View *view = cmd->view; + + // TODO(allen): this isn't really super awesome, could have issues if + // the file view get's change out under us. + view->next_mode = {}; + cmd_in->bind.function(cmd->system, cmd, cmd_in->bind); + view->mode = view->next_mode; +} + +internal void +app_links_init(System_Functions *system, void *data, int size){ + app_links.memory = data; + app_links.memory_size = size; + + app_links.exec_command_keep_stack = external_exec_command_keep_stack; + app_links.push_parameter = external_push_parameter; + app_links.push_memory = external_push_memory; + app_links.clear_parameters = external_clear_parameters; + + app_links.directory_get_hot = external_directory_get_hot; + app_links.file_exists = system->file_exists; + app_links.directory_cd = system->directory_cd; + app_links.get_file_list = external_get_file_list; + app_links.free_file_list = external_free_file_list; + + app_links.get_buffer_first = external_get_buffer_first; + app_links.get_buffer_next = external_get_buffer_next; + + app_links.get_buffer = external_get_buffer; + app_links.get_active_buffer = external_get_active_buffer; + app_links.get_parameter_buffer = external_get_parameter_buffer; + app_links.get_buffer_by_name = external_get_buffer_by_name; + + app_links.refresh_buffer = external_refresh_buffer; + app_links.buffer_seek_delimiter = external_buffer_seek_delimiter; + app_links.buffer_seek_string = external_buffer_seek_string; + app_links.buffer_read_range = external_buffer_read_range; + app_links.buffer_replace_range = external_buffer_replace_range; + + app_links.get_view_first = external_get_view_first; + app_links.get_view_next = external_get_view_next; + + app_links.get_view = external_get_view; + app_links.get_active_view = external_get_active_view; + + app_links.refresh_view = external_refresh_view; + app_links.view_set_cursor = external_view_set_cursor; + app_links.view_set_mark = external_view_set_mark; + app_links.view_set_highlight = external_view_set_highlight; + app_links.view_set_buffer = external_view_set_buffer; + + app_links.get_user_input = external_get_user_input; + + app_links.start_query_bar = external_start_query_bar; + app_links.end_query_bar = external_end_query_bar; + + app_links.change_theme = external_change_theme; + app_links.change_font = external_change_font; + app_links.set_theme_colors = external_set_theme_colors; +} + +internal void +setup_ui_commands(Command_Map *commands, Partition *part, Command_Map *parent){ + map_init(commands, part, 32, parent); + + commands->vanilla_keyboard_default.function = command_null; + + // TODO(allen): This is hacky, when the new UI stuff happens, let's fix it, and by that + // I mean actually fix it, don't just say you fixed it with something stupid again. + u8 mdfr; + u8 mdfr_array[] = {MDFR_NONE, MDFR_SHIFT, MDFR_CTRL, MDFR_SHIFT | MDFR_CTRL}; + for (i32 i = 0; i < 4; ++i){ + mdfr = mdfr_array[i]; + map_add(commands, key_left, mdfr, command_null); + map_add(commands, key_right, mdfr, command_null); + map_add(commands, key_up, mdfr, command_null); + map_add(commands, key_down, mdfr, command_null); + map_add(commands, key_back, mdfr, command_null); + map_add(commands, key_esc, mdfr, command_close_minor_view); + } +} + +internal void +setup_file_commands(Command_Map *commands, Partition *part, Command_Map *parent){ + map_init(commands, part, 10, parent); +} + +internal void +setup_top_commands(Command_Map *commands, Partition *part, Command_Map *parent){ + map_init(commands, part, 10, parent); +} + +internal void +setup_command_table(){ +#define SET(n) command_table[cmdid_##n] = command_##n + + SET(null); + SET(write_character); + SET(seek_left); + SET(seek_right); + SET(seek_whitespace_up); + SET(seek_whitespace_down); + SET(word_complete); + SET(set_mark); + SET(copy); + SET(cut); + SET(paste); + SET(paste_next); + SET(delete_range); + SET(timeline_scrub); + SET(undo); + SET(redo); + SET(history_backward); + SET(history_forward); + SET(interactive_new); + SET(interactive_open); + SET(reopen); + SET(save); + SET(interactive_save_as); + SET(change_active_panel); + SET(interactive_switch_buffer); + SET(interactive_kill_buffer); + SET(kill_buffer); + SET(toggle_line_wrap); + SET(to_uppercase); + SET(to_lowercase); + SET(toggle_show_whitespace); + SET(clean_all_lines); + SET(eol_dosify); + SET(eol_nixify); + SET(auto_tab_range); + SET(open_panel_vsplit); + SET(open_panel_hsplit); + SET(close_panel); + SET(move_left); + SET(move_right); + SET(delete); + SET(backspace); + SET(move_up); + SET(move_down); + SET(seek_end_of_line); + SET(seek_beginning_of_line); + SET(page_up); + SET(page_down); + SET(open_color_tweaker); + SET(cursor_mark_swap); + SET(open_menu); + SET(set_settings); + SET(command_line); + +#undef SET +} + +// App Functions + +internal void +app_hardcode_styles(Models *models){ + Interactive_Style file_info_style; + Style *styles, *style; + styles = models->styles.styles; + style = styles; + + i16 fonts = 1; + models->global_font.font_id = fonts + 0; + models->global_font.font_changed = 0; + + ///////////////// + style_set_name(style, make_lit_string("4coder")); + + style->main.back_color = 0xFF0C0C0C; + style->main.margin_color = 0xFF181818; + style->main.margin_hover_color = 0xFF252525; + style->main.margin_active_color = 0xFF323232; + style->main.cursor_color = 0xFF00EE00; + style->main.highlight_color = 0xFFDDEE00; + style->main.mark_color = 0xFF494949; + style->main.default_color = 0xFF90B080; + style->main.at_cursor_color = style->main.back_color; + style->main.at_highlight_color = 0xFFFF44DD; + style->main.comment_color = 0xFF2090F0; + style->main.keyword_color = 0xFFD08F20; + style->main.str_constant_color = 0xFF50FF30; + style->main.char_constant_color = style->main.str_constant_color; + style->main.int_constant_color = style->main.str_constant_color; + style->main.float_constant_color = style->main.str_constant_color; + style->main.bool_constant_color = style->main.str_constant_color; + style->main.include_color = style->main.str_constant_color; + style->main.preproc_color = style->main.default_color; + style->main.special_character_color = 0xFFFF0000; + + style->main.paste_color = 0xFFDDEE00; + style->main.undo_color = 0xFF00DDEE; + + style->main.highlight_junk_color = 0xff3a0000; + style->main.highlight_white_color = 0xff003a3a; + + file_info_style.bar_color = 0xFF888888; + file_info_style.bar_active_color = 0xFF666666; + file_info_style.base_color = 0xFF000000; + file_info_style.pop1_color = 0xFF4444AA; + file_info_style.pop2_color = 0xFFFF0000; + style->main.file_info_style = file_info_style; + ++style; + + ///////////////// + style_set_name(style, make_lit_string("Handmade Hero")); + + style->main.back_color = 0xFF161616; + style->main.margin_color = 0xFF262626; + style->main.margin_hover_color = 0xFF333333; + style->main.margin_active_color = 0xFF404040; + style->main.cursor_color = 0xFF40FF40; + style->main.at_cursor_color = style->main.back_color; + style->main.mark_color = 0xFF808080; + style->main.highlight_color = 0xFF703419; + style->main.at_highlight_color = 0xFFCDAA7D; + style->main.default_color = 0xFFCDAA7D; + style->main.comment_color = 0xFF7F7F7F; + style->main.keyword_color = 0xFFCD950C; + style->main.str_constant_color = 0xFF6B8E23; + style->main.char_constant_color = style->main.str_constant_color; + style->main.int_constant_color = style->main.str_constant_color; + style->main.float_constant_color = style->main.str_constant_color; + style->main.bool_constant_color = style->main.str_constant_color; + style->main.include_color = style->main.str_constant_color; + style->main.preproc_color = style->main.default_color; + style->main.special_character_color = 0xFFFF0000; + + style->main.paste_color = 0xFFFFBB00; + style->main.undo_color = 0xFFFF00BB; + style->main.undo_color = 0xFF80005D; + + style->main.highlight_junk_color = 0xFF3A0000; + style->main.highlight_white_color = 0xFF003A3A; + + file_info_style.bar_color = 0xFFCACACA; + file_info_style.bar_active_color = 0xFFA8A8A8; + file_info_style.base_color = 0xFF000000; + file_info_style.pop1_color = 0xFF03CF0C; + file_info_style.pop2_color = 0xFFFF0000; + style->main.file_info_style = file_info_style; + ++style; + + ///////////////// + style_set_name(style, make_lit_string("Twilight")); + + style->main.back_color = 0xFF090D12; + style->main.margin_color = 0xFF1A2634; + style->main.margin_hover_color = 0xFF2D415B; + style->main.margin_active_color = 0xFF405D82; + style->main.cursor_color = 0xFFEEE800; + style->main.at_cursor_color = style->main.back_color; + style->main.mark_color = 0xFF8BA8CC; + style->main.highlight_color = 0xFF037A7B; + style->main.at_highlight_color = 0xFFFEB56C; + style->main.default_color = 0xFFB7C19E; + style->main.comment_color = 0xFF20ECF0; + style->main.keyword_color = 0xFFD86909; + style->main.str_constant_color = 0xFFC4EA5D; + style->main.char_constant_color = style->main.str_constant_color; + style->main.int_constant_color = style->main.str_constant_color; + style->main.float_constant_color = style->main.str_constant_color; + style->main.bool_constant_color = style->main.str_constant_color; + style->main.include_color = style->main.str_constant_color; + style->main.preproc_color = style->main.default_color; + style->main.special_character_color = 0xFFFF0000; + + style->main.paste_color = 0xFFDDEE00; + style->main.undo_color = 0xFF00DDEE; + + style->main.highlight_junk_color = 0xff3a0000; + style->main.highlight_white_color = 0xFF151F2A; + + file_info_style.bar_color = 0xFF315E68; + file_info_style.bar_active_color = 0xFF0F3C46; + file_info_style.base_color = 0xFF000000; + file_info_style.pop1_color = 0xFF1BFF0C; + file_info_style.pop2_color = 0xFFFF200D; + style->main.file_info_style = file_info_style; + ++style; + + ///////////////// + style_set_name(style, make_lit_string("Wolverine")); + + style->main.back_color = 0xFF070711; + style->main.margin_color = 0xFF111168; + style->main.margin_hover_color = 0xFF191996; + style->main.margin_active_color = 0xFF2121C3; + style->main.cursor_color = 0xFF7082F9; + style->main.at_cursor_color = 0xFF000014; + style->main.mark_color = 0xFF4b5028; + style->main.highlight_color = 0xFFDDEE00; + style->main.at_highlight_color = 0xFF000019; + style->main.default_color = 0xFF8C9740; + style->main.comment_color = 0xFF3A8B29; + style->main.keyword_color = 0xFFD6B109; + style->main.str_constant_color = 0xFFAF5FA7; + style->main.char_constant_color = style->main.str_constant_color; + style->main.int_constant_color = style->main.str_constant_color; + style->main.float_constant_color = style->main.str_constant_color; + style->main.bool_constant_color = style->main.str_constant_color; + style->main.include_color = style->main.str_constant_color; + style->main.preproc_color = style->main.default_color; + style->main.special_character_color = 0xFFFF0000; + + style->main.paste_color = 0xFF900090; + style->main.undo_color = 0xFF606090; + + style->main.highlight_junk_color = 0xff3a0000; + style->main.highlight_white_color = 0xff003a3a; + + file_info_style.bar_color = 0xFF7082F9; + file_info_style.bar_active_color = 0xFF4E60D7; + file_info_style.base_color = 0xFF000000; + file_info_style.pop1_color = 0xFFFAFA15; + file_info_style.pop2_color = 0xFFD20000; + style->main.file_info_style = file_info_style; + ++style; + + ///////////////// + style_set_name(style, make_lit_string("stb")); + + style->main.back_color = 0xFFD6D6D6; + style->main.margin_color = 0xFF9E9E9E; + style->main.margin_hover_color = 0xFF7E7E7E; + style->main.margin_active_color = 0xFF5C5C5C; + style->main.cursor_color = 0xFF000000; + style->main.at_cursor_color = 0xFFD6D6D6; + style->main.mark_color = 0xFF525252; + style->main.highlight_color = 0xFF0044FF; + style->main.at_highlight_color = 0xFFD6D6D6; + style->main.default_color = 0xFF000000; + style->main.comment_color = 0xFF005800; + style->main.keyword_color = 0xFF000000; + style->main.str_constant_color = 0xFF000000; + style->main.char_constant_color = style->main.str_constant_color; + style->main.int_constant_color = style->main.str_constant_color; + style->main.float_constant_color = style->main.str_constant_color; + style->main.bool_constant_color = style->main.str_constant_color; + style->main.include_color = style->main.str_constant_color; + style->main.preproc_color = style->main.default_color; + style->main.special_character_color = 0xFF9A0000; + + style->main.paste_color = 0xFF00B8B8; + style->main.undo_color = 0xFFB800B8; + + style->main.highlight_junk_color = 0xFFFF7878; + style->main.highlight_white_color = 0xFFBCBCBC; + + file_info_style.bar_color = 0xFF606060; + file_info_style.bar_active_color = 0xFF3E3E3E; + file_info_style.base_color = 0xFF000000; + file_info_style.pop1_color = 0xFF1111DC; + file_info_style.pop2_color = 0xFFE80505; + style->main.file_info_style = file_info_style; + ++style; + + models->styles.count = (i32)(style - styles); + models->styles.max = ArrayCount(models->styles.styles); + style_copy(&models->style, models->styles.styles); +} + +char *_4coder_get_extension(const char *filename, int len, int *extension_len){ + char *c = (char*)(filename + len - 1); + char *end = c; + while (*c != '.' && c > filename) --c; + *extension_len = (int)(end - c); + return c+1; +} + +bool _4coder_str_match(const char *a, int len_a, const char *b, int len_b){ + bool result = 0; + if (len_a == len_b){ + char *end = (char*)(a + len_a); + while (a < end && *a == *b){ + ++a; ++b; + } + if (a == end) result = 1; + } + return result; +} + +enum Command_Line_Action{ + CLAct_Nothing, + CLAct_Ignore, + CLAct_UserFile, + CLAct_CustomDLL, + CLAct_InitialFilePosition, + CLAct_WindowSize, + CLAct_WindowMaximize, + CLAct_WindowPosition, + CLAct_Count +}; + +void +init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings, + Command_Line_Parameters clparams){ + char *arg; + Command_Line_Action action = CLAct_Nothing; + i32 i,index; + b32 strict = 0; + + settings->init_files_max = ArrayCount(settings->init_files); + for (i = 1; i <= clparams.argc; ++i){ + if (i == clparams.argc) arg = ""; + else arg = clparams.argv[i]; + switch (action){ + case CLAct_Nothing: + { + if (arg[0] == '-'){ + action = CLAct_Ignore; + switch (arg[1]){ + case 'u': action = CLAct_UserFile; strict = 0; break; + case 'U': action = CLAct_UserFile; strict = 1; break; + + case 'd': action = CLAct_CustomDLL; strict = 0; break; + case 'D': action = CLAct_CustomDLL; strict = 1; break; + + case 'i': action = CLAct_InitialFilePosition; break; + + case 'w': action = CLAct_WindowSize; break; + case 'W': action = CLAct_WindowMaximize; break; + case 'p': action = CLAct_WindowPosition; break; + } + } + else if (arg[0] != 0){ + if (settings->init_files_count < settings->init_files_max){ + index = settings->init_files_count++; + settings->init_files[index] = arg; + } + } + }break; + + case CLAct_UserFile: + { + settings->user_file_is_strict = strict; + if (i < clparams.argc){ + settings->user_file = clparams.argv[i]; + } + action = CLAct_Nothing; + }break; + + case CLAct_CustomDLL: + { + plat_settings->custom_dll_is_strict = strict; + if (i < clparams.argc){ + plat_settings->custom_dll = clparams.argv[i]; + } + action = CLAct_Nothing; + }break; + + case CLAct_InitialFilePosition: + { + if (i < clparams.argc){ + settings->initial_line = str_to_int(clparams.argv[i]); + } + action = CLAct_Nothing; + }break; + + case CLAct_WindowSize: + { + if (i + 1 < clparams.argc){ + plat_settings->set_window_size = 1; + plat_settings->window_w = str_to_int(clparams.argv[i]); + plat_settings->window_h = str_to_int(clparams.argv[i+1]); + + ++i; + } + action = CLAct_Nothing; + }break; + + case CLAct_WindowMaximize: + { + --i; + plat_settings->maximize_window = 1; + action = CLAct_Nothing; + }break; + + case CLAct_WindowPosition: + { + if (i + 1 < clparams.argc){ + plat_settings->set_window_pos = 1; + plat_settings->window_x = str_to_int(clparams.argv[i]); + plat_settings->window_y = str_to_int(clparams.argv[i+1]); + + ++i; + } + action = CLAct_Nothing; + }break; + } + } +} + +internal App_Vars* +app_setup_memory(Application_Memory *memory){ + Partition _partition = partition_open(memory->vars_memory, memory->vars_memory_size); + App_Vars *vars = push_struct(&_partition, App_Vars); + Assert(vars); + *vars = {}; + vars->models.mem.part = _partition; + + general_memory_open(&vars->models.mem.general, memory->target_memory, memory->target_memory_size); + + return(vars); +} + +internal i32 +execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){ + i32 result; + char message[] = "tool was not specified or is invalid"; + result = sizeof(message) - 1; + memcpy(memory, message, result); + if (clparams.argc > 2){ + if (match(clparams.argv[2], "version")){ + result = sizeof(VERSION) - 1; + memcpy(memory, VERSION, result); + } + } + return(result); +} + +App_Read_Command_Line_Sig(app_read_command_line){ + App_Vars *vars; + i32 out_size = 0; + + if (clparams.argc > 1 && match(clparams.argv[1], "-T")){ + out_size = execute_special_tool(memory->target_memory, memory->target_memory_size, clparams); + } + else{ + vars = app_setup_memory(memory); + if (clparams.argc > 1){ + init_command_line_settings(&vars->models.settings, plat_settings, clparams); + } + else{ + vars->models.settings = {}; + } + *files = vars->models.settings.init_files; + *file_count = &vars->models.settings.init_files_count; + } + + return(out_size); +} + +extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){ + int result = 0; + + if (target_x != *scroll_x){ + *scroll_x = target_x; + result = 1; + } + if (target_y != *scroll_y){ + *scroll_y = target_y; + result = 1; + } + + return(result); +} + + +App_Init_Sig(app_init){ + App_Vars *vars; + Models *models; + Partition *partition; + Panel *panels, *panel; + Panel_Divider *dividers, *div; + i32 panel_max_count; + i32 divider_max_count; + + app_links_init(system, memory->user_memory, memory->user_memory_size); + + vars = (App_Vars*)memory->vars_memory; + models = &vars->models; + + models->config_api = api; + app_links.cmd_context = &vars->command_data; + + partition = &models->mem.part; + target->partition = partition; + + { + i32 i; + + panel_max_count = models->layout.panel_max_count = 16; + divider_max_count = panel_max_count - 1; + models->layout.panel_count = 0; + + panels = push_array(partition, Panel, panel_max_count); + models->layout.panels = panels; + + dll_init_sentinel(&models->layout.free_sentinel); + dll_init_sentinel(&models->layout.used_sentinel); + + panel = panels; + for (i = 0; i < panel_max_count; ++i, ++panel){ + dll_insert(&models->layout.free_sentinel, panel); + } + + dividers = push_array(partition, Panel_Divider, divider_max_count); + models->layout.dividers = dividers; + + div = dividers; + for (i = 0; i < divider_max_count-1; ++i, ++div){ + div->next = (div + 1); + } + div->next = 0; + models->layout.free_divider = dividers; + } + + { + View *vptr = 0; + i32 i = 0; + i32 max = 0; + + vars->live_set.count = 0; + vars->live_set.max = panel_max_count; + + vars->live_set.views = push_array(partition, View, vars->live_set.max); + + dll_init_sentinel(&vars->live_set.free_sentinel); + + max = vars->live_set.max; + vptr = vars->live_set.views; + for (i = 0; i < max; ++i, ++vptr){ + dll_insert(&vars->live_set.free_sentinel, vptr); + } + } + + { + Command_Map *global; + i32 wanted_size = 0; + b32 did_top = 0; + b32 did_file = 0; + + models->scroll_rule = fallback_scroll_rule; + + setup_command_table(); + + global = &models->map_top; + Assert(models->config_api.get_bindings != 0); + + wanted_size = models->config_api.get_bindings(app_links.memory, app_links.memory_size); + + if (wanted_size <= app_links.memory_size){ + Command_Map *map_ptr = 0; + Binding_Unit *unit, *end; + i32 user_map_count; + + unit = (Binding_Unit*)app_links.memory; + if (unit->type == unit_header && unit->header.error == 0){ + end = unit + unit->header.total_size; + + user_map_count = unit->header.user_map_count; + + models->map_id_table = push_array( + &models->mem.part, i32, user_map_count); + + models->user_maps = push_array( + &models->mem.part, Command_Map, user_map_count); + + models->user_map_count = user_map_count; + + for (++unit; unit < end; ++unit){ + switch (unit->type){ + case unit_map_begin: + { + int table_max = unit->map_begin.bind_count * 3 / 2; + int mapid = unit->map_begin.mapid; + if (mapid == mapid_global){ + map_ptr = &models->map_top; + map_init(map_ptr, &models->mem.part, table_max, global); + did_top = 1; + } + else if (mapid == mapid_file){ + map_ptr = &models->map_file; + map_init(map_ptr, &models->mem.part, table_max, global); + did_file = 1; + } + else if (mapid < mapid_global){ + i32 index = app_get_or_add_map_index(models, mapid); + Assert(index < user_map_count); + map_ptr = models->user_maps + index; + map_init(map_ptr, &models->mem.part, table_max, global); + } + else map_ptr = 0; + }break; + + case unit_inherit: + if (map_ptr){ + Command_Map *parent = 0; + int mapid = unit->map_inherit.mapid; + if (mapid == mapid_global) parent = &models->map_top; + else if (mapid == mapid_file) parent = &models->map_file; + else if (mapid < mapid_global){ + i32 index = app_get_or_add_map_index(models, mapid); + if (index < user_map_count) parent = models->user_maps + index; + else parent = 0; + } + map_ptr->parent = parent; + }break; + + case unit_binding: + if (map_ptr){ + Command_Function func = 0; + if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count) + func = command_table[unit->binding.command_id]; + if (func){ + if (unit->binding.code == 0 && unit->binding.modifiers == 0){ + map_ptr->vanilla_keyboard_default.function = func; + map_ptr->vanilla_keyboard_default.custom_id = unit->binding.command_id; + } + else{ + map_add(map_ptr, unit->binding.code, unit->binding.modifiers, func, unit->binding.command_id); + } + } + } + break; + + case unit_callback: + if (map_ptr){ + Command_Function func = command_user_callback; + Custom_Command_Function *custom = unit->callback.func; + if (func){ + if (unit->callback.code == 0 && unit->callback.modifiers == 0){ + map_ptr->vanilla_keyboard_default.function = func; + map_ptr->vanilla_keyboard_default.custom = custom; + } + else{ + map_add(map_ptr, unit->callback.code, unit->callback.modifiers, func, custom); + } + } + } + break; + + case unit_hook: + { + int hook_id = unit->hook.hook_id; + if (hook_id >= 0){ + if (hook_id < hook_type_count){ + models->hooks[hook_id] = (Hook_Function*)unit->hook.func; + } + else{ + models->scroll_rule = (Scroll_Rule_Function*)unit->hook.func; + } + } + }break; + } + } + } + } + + memset(app_links.memory, 0, wanted_size); + if (!did_top) setup_top_commands(&models->map_top, &models->mem.part, global); + if (!did_file) setup_file_commands(&models->map_file, &models->mem.part, global); + +#if !defined(FRED_SUPER) + models->hooks[hook_start] = 0; +#endif + + setup_ui_commands(&models->map_ui, &models->mem.part, global); + + models->font_set = &target->font_set; + + font_set_init(models->font_set, partition, 16, 5); + } + + { + struct Font_Setup{ + char *c_file_name; + i32 file_name_len; + char *c_name; + i32 name_len; + i32 pt_size; + }; + +#define LitStr(n) n, sizeof(n)-1 + + Font_Setup font_setup[] = { + {LitStr("LiberationSans-Regular.ttf"), + LitStr("liberation sans"), + 16}, + + {LitStr("liberation-mono.ttf"), + LitStr("liberation mono"), + 16}, + + {LitStr("Hack-Regular.ttf"), + LitStr("hack"), + 16}, + + {LitStr("CutiveMono-Regular.ttf"), + LitStr("cutive mono"), + 16}, + + {LitStr("Inconsolata-Regular.ttf"), + LitStr("inconsolata"), + 16}, + + }; + i32 font_count = ArrayCount(font_setup); + + for (i32 i = 0; i < font_count; ++i){ + String file_name = make_string(font_setup[i].c_file_name, + font_setup[i].file_name_len); + String name = make_string(font_setup[i].c_name, + font_setup[i].name_len); + i32 pt_size = font_setup[i].pt_size; + + font_set_add(partition, models->font_set, file_name, name, pt_size); + } + } + + // NOTE(allen): file setup + { + models->working_set.file_count = 0; + models->working_set.file_max = 119; + models->working_set.files = push_array( + partition, Editing_File, models->working_set.file_max + 1); + + models->working_set.files[0].state.is_dummy = 1; + + dll_init_sentinel(&models->working_set.free_sentinel); + dll_init_sentinel(&models->working_set.used_sentinel); + + Editing_File *file = models->working_set.files + 1; + i32 max = models->working_set.file_max; + for (i32 i = 0; i < max; ++i, ++file){ + dll_insert(&models->working_set.free_sentinel, &file->node); + } + + models->working_set.table.max = models->working_set.file_max * 3 / 2; + models->working_set.table.count = 0; + models->working_set.table.table = push_array( + partition, File_Table_Entry, models->working_set.table.max); + memset(models->working_set.table.table, 0, sizeof(File_Table_Entry) * models->working_set.table.max); + } + + // NOTE(allen): clipboard setup + models->working_set.clipboard_max_size = ArrayCount(models->working_set.clipboards); + models->working_set.clipboard_size = 0; + models->working_set.clipboard_current = 0; + models->working_set.clipboard_rolling = 0; + + // TODO(allen): more robust allocation solution for the clipboard + if (clipboard.str){ + String *dest = working_set_next_clipboard_string(&models->mem.general, &models->working_set, clipboard.size); + copy(dest, make_string((char*)clipboard.str, clipboard.size)); + } + + // NOTE(allen): delay setup + models->delay1.general = &models->mem.general; + models->delay1.max = 16; + models->delay1.acts = (Delayed_Action*)general_memory_allocate( + &models->mem.general, models->delay1.max*sizeof(Delayed_Action), 0); + + models->delay2.general = &models->mem.general; + models->delay2.max = 16; + models->delay2.acts = (Delayed_Action*)general_memory_allocate( + &models->mem.general, models->delay2.max*sizeof(Delayed_Action), 0); + + // NOTE(allen): style setup + app_hardcode_styles(models); + + models->palette_size = 40; + models->palette = push_array(partition, u32, models->palette_size); + + // NOTE(allen): init first panel + Panel_And_ID p = layout_alloc_panel(&models->layout); + panel_make_empty(system, exchange, vars, p.panel); + models->layout.active_panel = p.id; + + String hdbase = make_fixed_width_string(models->hot_dir_base_); + hot_directory_init(&models->hot_directory, hdbase, current_directory, system->slash); + + // NOTE(allen): child proc list setup + i32 max_children = 16; + partition_align(partition, 8); + vars->cli_processes.procs = push_array(partition, CLI_Process, max_children); + vars->cli_processes.max = max_children; + vars->cli_processes.count = 0; + + // NOTE(allen): sys app binding setup + vars->sys_app_max = exchange->file.max; + vars->sys_app_count = 0; + vars->sys_app_bindings = (Sys_App_Binding*)push_array(partition, Sys_App_Binding, vars->sys_app_max); + + // NOTE(allen): parameter setup + models->buffer_param_max = 32; + models->buffer_param_count = 0; + models->buffer_param_indices = push_array(partition, i32, models->buffer_param_max); +} + +internal App_Open_File_Result +app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *working_set, String filename){ + Get_File_Result file; + i32 file_id; + App_Open_File_Result result = {}; + + result.file = working_set_contains(working_set, filename); + if (result.file == 0){ + result.is_new = 1; + file = working_set_get_available_file(working_set); + if (file.file){ + result.file = file.file; + file_id = exchange_request_file(exchange, filename.str, filename.size); + if (file_id){ + file_init_strings(result.file); + file_set_name(working_set, result.file, filename.str); + file_set_to_loading(result.file); + table_add(&working_set->table, result.file->name.source_path, file.index); + + result.sys_id = file_id; + result.file_index = file.index; + } + else{ + working_set_free_file(working_set, file.file); + file.file = 0; + } + } + } + + return(result); +} + +App_Step_Sig(app_step){ + ProfileStart(OS_syncing); + Application_Step_Result app_result = *result; + app_result.redraw = force_redraw; + + App_Vars *vars = (App_Vars*)memory->vars_memory; + Models *models = &vars->models; + target->partition = &models->mem.part; + + if (first_step || !time_step){ + app_result.redraw = 1; + } + + // NOTE(allen): OS clipboard event handling + if (clipboard.str){ + String *dest = working_set_next_clipboard_string(&models->mem.general, &models->working_set, clipboard.size); + dest->size = eol_convert_in(dest->str, clipboard.str, clipboard.size); + } + + // TODO(allen): profile this make sure it's not costing me too much power. + // NOTE(allen): check files are up to date + { + File_Node *node, *used_nodes; + Editing_File *file; + u64 time_stamp; + + used_nodes = &models->working_set.used_sentinel; + for (dll_items(node, used_nodes)){ + file = (Editing_File*)node; + + time_stamp = system->file_time_stamp(make_c_str(file->name.source_path)); + + // TODO(allen): This is a bit wasteful! Let's dial it in a bit. + if (time_stamp > 0){ + file->state.last_sys_write_time = time_stamp; + if (file->state.last_sys_write_time != file->state.last_4ed_write_time){ + app_result.redraw = 1; + } + } + } + } + + // NOTE(allen): update child processes + if (time_step){ + Temp_Memory temp = begin_temp_memory(&models->mem.part); + u32 max = Kbytes(32); + char *dest = push_array(&models->mem.part, char, max); + u32 amount; + + i32 count = vars->cli_processes.count; + for (i32 i = 0; i < count; ++i){ + CLI_Process *proc = vars->cli_processes.procs + i; + Editing_File *out_file = proc->out_file; + + if (out_file != 0){ + i32 new_cursor = out_file->state.cursor_pos; + + for (system->cli_begin_update(&proc->cli); + system->cli_update_step(&proc->cli, dest, max, &amount);){ + amount = eol_in_place_convert_in(dest, amount); + + i32 end = buffer_size(&out_file->state.buffer); + file_replace_range(system, models, out_file, + end, end, dest, amount, end + amount, 1); + app_result.redraw = 1; + new_cursor = end + amount; + } + + if (system->cli_end_update(&proc->cli)){ + *proc = vars->cli_processes.procs[--count]; + --i; + + char str_space[256]; + String str = make_fixed_width_string(str_space); + append(&str, "exited with code "); + append_int_to_str(proc->cli.exit, &str); + + i32 end = buffer_size(&out_file->state.buffer); + file_replace_range(system, models, out_file, + end, end, str.str, str.size, end + str.size, 1); + app_result.redraw = 1; + new_cursor = end + str.size; + } + + new_cursor = 0; + + for (View_Iter iter = file_view_iter_init(&models->layout, out_file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + view_cursor_move(iter.view, new_cursor); + } + } + } + + vars->cli_processes.count = count; + end_temp_memory(temp); + } + + // NOTE(allen): reorganizing panels on screen + { + i32 prev_width = models->layout.full_width; + i32 prev_height = models->layout.full_height; + i32 current_width = target->width; + i32 current_height = target->height; + + Panel *panel, *used_panels; + View *view; + + models->layout.full_width = current_width; + models->layout.full_height = current_height; + + if (prev_width != current_width || prev_height != current_height){ + layout_refit(&models->layout, prev_width, prev_height); + + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + view = panel->view; + Assert(view); + // TODO(allen): All responses to a panel changing size should + // be handled in the same place. + view_change_size(system, &models->mem.general, view); + } + + app_result.redraw = 1; + } + } + + // NOTE(allen): prepare input information + Key_Summary key_data = {}; + for (i32 i = 0; i < input->press_count; ++i){ + key_data.keys[key_data.count++] = input->press[i]; + } + for (i32 i = 0; i < input->hold_count; ++i){ + key_data.keys[key_data.count++] = input->hold[i]; + } + + mouse->wheel = -mouse->wheel; + + ProfileEnd(OS_syncing); + + ProfileStart(hover_status); + // NOTE(allen): detect mouse hover status + i32 mx = mouse->x; + i32 my = mouse->y; + b32 mouse_in_edit_area = 0; + b32 mouse_in_margin_area = 0; + Panel *mouse_panel, *used_panels; + + used_panels = &models->layout.used_sentinel; + for (dll_items(mouse_panel, used_panels)){ + if (hit_check(mx, my, mouse_panel->inner)){ + mouse_in_edit_area = 1; + break; + } + else if (hit_check(mx, my, mouse_panel->full)){ + mouse_in_margin_area = 1; + break; + } + } + + if (!(mouse_in_edit_area || mouse_in_margin_area)){ + mouse_panel = 0; + } + + b32 mouse_on_divider = 0; + b32 mouse_divider_vertical = 0; + i32 mouse_divider_id = 0; + i32 mouse_divider_side = 0; + + if (mouse_in_margin_area){ + Panel *panel = mouse_panel; + if (mx >= panel->inner.x0 && mx < panel->inner.x1){ + mouse_divider_vertical = 0; + if (my > panel->inner.y0){ + mouse_divider_side = -1; + } + else{ + mouse_divider_side = 1; + } + } + else{ + mouse_divider_vertical = 1; + if (mx > panel->inner.x0){ + mouse_divider_side = -1; + } + else{ + mouse_divider_side = 1; + } + } + + if (models->layout.panel_count > 1){ + i32 which_child; + mouse_divider_id = panel->parent; + which_child = panel->which_child; + for (;;){ + Divider_And_ID div = layout_get_divider(&models->layout, mouse_divider_id); + + if (which_child == mouse_divider_side && + div.divider->v_divider == mouse_divider_vertical){ + mouse_on_divider = 1; + break; + } + + if (mouse_divider_id == models->layout.root){ + break; + } + else{ + mouse_divider_id = div.divider->parent; + which_child = div.divider->which_child; + } + } + } + else{ + mouse_on_divider = 0; + mouse_divider_id = 0; + } + } + ProfileEnd(hover_status); + + // NOTE(allen): prepare to start executing commands + ProfileStart(prepare_commands); + + Command_Data *cmd = &vars->command_data; + + cmd->models = models; + cmd->vars = vars; + cmd->system = system; + cmd->exchange = exchange; + cmd->live_set = &vars->live_set; + + cmd->panel = models->layout.panels + models->layout.active_panel; + cmd->view = cmd->panel->view; + + cmd->screen_width = target->width; + cmd->screen_height = target->height; + + cmd->key = {}; + + Temp_Memory param_stack_temp = begin_temp_memory(&models->mem.part); + cmd->part = partition_sub_part(&models->mem.part, 16 << 10); + + if (first_step){ + if (models->hooks[hook_start]){ + models->hooks[hook_start](&app_links); + cmd->part.pos = 0; + } + + i32 i; + String file_name; + Panel *panel = models->layout.used_sentinel.next; + for (i = 0; i < models->settings.init_files_count; ++i, panel = panel->next){ + file_name = make_string_slowly(models->settings.init_files[i]); + + if (i < models->layout.panel_count){ + delayed_open(&models->delay1, file_name, panel); + if (i == 0){ + delayed_set_line(&models->delay1, panel, models->settings.initial_line); + } + } + else{ + delayed_open_background(&models->delay1, file_name); + } + } + } + ProfileEnd(prepare_commands); + + // NOTE(allen): process the command_coroutine if it is unfinished + ProfileStart(command_coroutine); + b8 consumed_input[6] = {0}; + + if (models->command_coroutine != 0){ + Coroutine *command_coroutine = models->command_coroutine; + u32 get_flags = models->command_coroutine_flags[0]; + u32 abort_flags = models->command_coroutine_flags[1]; + + get_flags |= abort_flags; + + if ((get_flags & EventOnAnyKey) || (get_flags & EventOnEsc)){ + for (i32 key_i = 0; key_i < key_data.count; ++key_i){ + Key_Event_Data key = get_single_key(&key_data, key_i); + View *view = cmd->view; + b32 pass_in = 0; + cmd->key = key; + + Command_Map *map = 0; + if (view) map = view->map; + if (map == 0) map = &models->map_top; + Command_Binding cmd_bind = map_extract_recursive(map, key); + + User_Input user_in; + user_in.type = UserInputKey; + user_in.key = key; + user_in.command = (unsigned long long)cmd_bind.custom; + user_in.abort = 0; + + if ((EventOnEsc & abort_flags) && key.keycode == key_esc){ + user_in.abort = 1; + } + else if (EventOnAnyKey & abort_flags){ + user_in.abort = 1; + } + + if (EventOnAnyKey & get_flags){ + pass_in = 1; + consumed_input[0] = 1; + } + if (key.keycode == key_esc){ + if (EventOnEsc & get_flags){ + pass_in = 1; + } + consumed_input[1] = 1; + } + + if (pass_in){ + models->command_coroutine = system->resume_coroutine(command_coroutine, &user_in, models->command_coroutine_flags); + app_result.redraw = 1; + + // TOOD(allen): Deduplicate + // TODO(allen): Allow a view to clean up however it wants after a command + // finishes, or after transfering to another view mid command. + if (view != 0 && models->command_coroutine == 0){ + init_query_set(&view->query_set); + } + if (models->command_coroutine == 0) break; + } + } + } + + if (models->command_coroutine != 0 && (get_flags & EventOnMouse)){ + View *view = cmd->view; + b32 pass_in = 0; + + User_Input user_in; + user_in.type = UserInputMouse; + user_in.mouse = *mouse; + user_in.command = 0; + user_in.abort = 0; + + if (abort_flags & EventOnMouseMove){ + user_in.abort = 1; + } + if (get_flags & EventOnMouseMove){ + pass_in = 1; + consumed_input[2] = 1; + } + + if (mouse->press_l || mouse->release_l || mouse->l){ + if (abort_flags & EventOnLeftButton){ + user_in.abort = 1; + } + if (get_flags & EventOnLeftButton){ + pass_in = 1; + consumed_input[3] = 1; + } + } + + if (mouse->press_r || mouse->release_r || mouse->r){ + if (abort_flags & EventOnRightButton){ + user_in.abort = 1; + } + if (get_flags & EventOnRightButton){ + pass_in = 1; + consumed_input[4] = 1; + } + } + + if (mouse->wheel != 0){ + if (abort_flags & EventOnWheel){ + user_in.abort = 1; + } + if (get_flags & EventOnWheel){ + pass_in = 1; + consumed_input[5] = 1; + } + } + + if (pass_in){ + models->command_coroutine = system->resume_coroutine(command_coroutine, &user_in, + models->command_coroutine_flags); + app_result.redraw = 1; + + // TOOD(allen): Deduplicate + // TODO(allen): Allow a view to clean up however it wants after a command finishes, + // or after transfering to another view mid command. + if (view != 0 && models->command_coroutine == 0){ + init_query_set(&view->query_set); + } + } + } + } + + update_command_data(vars, cmd); + + ProfileEnd(command_coroutine); + + ProfileStart(frame_hook); + if (models->hooks[hook_frame]){ + if ((models->hooks[hook_frame])(&app_links)){ + app_result.redraw = 1; + } + } + ProfileStart(frame_hook); + + // NOTE(allen): pass raw input to the panels + ProfileStart(step); + + Input_Summary dead_input = {}; + dead_input.mouse.x = mouse->x; + dead_input.mouse.y = mouse->y; + + Input_Summary active_input = {}; + active_input.mouse.x = mouse->x; + active_input.mouse.y = mouse->y; + if (!consumed_input[0]){ + active_input.keys = key_data; + } + else if (!consumed_input[1]){ + for (i32 i = 0; i < key_data.count; ++i){ + Key_Event_Data key = get_single_key(&key_data, i); + if (key.keycode == key_esc){ + active_input.keys.count = 1; + active_input.keys.keys[0] = key; + break; + } + } + } + + Mouse_State mouse_state = *mouse; + + if (consumed_input[3]){ + mouse_state.l = 0; + mouse_state.press_l = 0; + mouse_state.release_l = 0; + } + + if (consumed_input[4]){ + mouse_state.r = 0; + mouse_state.press_r = 0; + mouse_state.release_r = 0; + } + + if (consumed_input[5]){ + mouse_state.wheel = 0; + } + + { + Panel *panel, *used_panels; + View *view; + b32 active; + + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + view = panel->view; + active = (panel == cmd->panel); + Input_Summary input = (active)?(active_input):(dead_input); + if (panel == mouse_panel && !mouse->out_of_window){ + input.mouse = mouse_state; + } + if (step_file_view(system, exchange, view, panel->inner, active, &input)){ + app_result.redraw = 1; + } + } + } + + update_command_data(vars, cmd); + ProfileEnd(step); + + // NOTE(allen): command execution + ProfileStart(command); + if (!consumed_input[0] || !consumed_input[1]){ + b32 consumed_input2[2] = {0}; + + for (i32 key_i = 0; key_i < key_data.count; ++key_i){ + if (models->command_coroutine != 0) break; + + switch (vars->state){ + case APP_STATE_EDIT: + { + Key_Event_Data key = get_single_key(&key_data, key_i); + b32 hit_esc = (key.keycode == key_esc); + cmd->key = key; + + if (hit_esc || !consumed_input[0]){ + View *view = cmd->view; + + Command_Map *map = 0; + if (view) map = view->map; + if (map == 0) map = &models->map_top; + Command_Binding cmd_bind = map_extract_recursive(map, key); + + if (cmd_bind.function){ + if (hit_esc){ + consumed_input2[1] = 1; + } + else{ + consumed_input2[0] = 1; + } + + Assert(models->command_coroutine == 0); + Coroutine *command_coroutine = system->create_coroutine(command_caller); + models->command_coroutine = command_coroutine; + + Command_In cmd_in; + cmd_in.cmd = cmd; + cmd_in.bind = cmd_bind; + + models->command_coroutine = system->launch_coroutine(models->command_coroutine, + &cmd_in, models->command_coroutine_flags); + models->prev_command = cmd_bind; + app_result.redraw = 1; + } + } + }break; + + case APP_STATE_RESIZING: + { + if (key_data.count > 0){ + vars->state = APP_STATE_EDIT; + } + }break; + } + } + + consumed_input[0] |= consumed_input2[0]; + consumed_input[1] |= consumed_input2[1]; + } + + update_command_data(vars, cmd); + ProfileEnd(command); + + ProfileStart(resizing); + // NOTE(allen): panel resizing + switch (vars->state){ + case APP_STATE_EDIT: + { + if (mouse->press_l && mouse_on_divider){ + vars->state = APP_STATE_RESIZING; + Divider_And_ID div = layout_get_divider(&models->layout, mouse_divider_id); + vars->resizing.divider = div.divider; + + i32 min, max; + { + i32 mid, MIN, MAX; + mid = div.divider->pos; + if (mouse_divider_vertical){ + MIN = 0; + MAX = MIN + models->layout.full_width; + } + else{ + MIN = 0; + MAX = MIN + models->layout.full_height; + } + min = MIN; + max = MAX; + + i32 divider_id = div.id; + do{ + Divider_And_ID other_div = layout_get_divider(&models->layout, divider_id); + b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical); + i32 pos = other_div.divider->pos; + if (divider_match && pos > mid && pos < max){ + max = pos; + } + else if (divider_match && pos < mid && pos > min){ + min = pos; + } + divider_id = other_div.divider->parent; + }while(divider_id != -1); + + Temp_Memory temp = begin_temp_memory(&models->mem.part); + i32 *divider_stack = push_array(&models->mem.part, i32, models->layout.panel_count); + i32 top = 0; + divider_stack[top++] = div.id; + + while (top > 0){ + Divider_And_ID other_div = layout_get_divider(&models->layout, divider_stack[--top]); + b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical); + i32 pos = other_div.divider->pos; + if (divider_match && pos > mid && pos < max){ + max = pos; + } + else if (divider_match && pos < mid && pos > min){ + min = pos; + } + if (other_div.divider->child1 != -1){ + divider_stack[top++] = other_div.divider->child1; + } + if (other_div.divider->child2 != -1){ + divider_stack[top++] = other_div.divider->child2; + } + } + + end_temp_memory(temp); + } + + vars->resizing.min = min; + vars->resizing.max = max; + } + }break; + + case APP_STATE_RESIZING: + { + app_result.redraw = 1; + if (mouse->l){ + Panel_Divider *divider = vars->resizing.divider; + if (divider->v_divider){ + divider->pos = mx; + } + else{ + divider->pos = my; + } + + if (divider->pos < vars->resizing.min){ + divider->pos = vars->resizing.min; + } + else if (divider->pos > vars->resizing.max){ + divider->pos = vars->resizing.max - 1; + } + + layout_fix_all_panels(&models->layout); + } + else{ + vars->state = APP_STATE_EDIT; + } + }break; + } + + if (mouse_in_edit_area && mouse_panel != 0 && mouse->press_l){ + models->layout.active_panel = (i32)(mouse_panel - models->layout.panels); + app_result.redraw = 1; + } + + update_command_data(vars, cmd); + ProfileEnd(resizing); + + // NOTE(allen): processing sys app bindings + ProfileStart(sys_app_bind_processing); + { + Mem_Options *mem = &models->mem; + General_Memory *general = &mem->general; + + for (i32 i = 0; i < vars->sys_app_count; ++i){ + Sys_App_Binding *binding; + b32 remove = 0; + b32 failed = 0; + binding = vars->sys_app_bindings + i; + + byte *data; + i32 size, max; + Editing_File *ed_file; + Editing_File_Preload preload_settings; + char *filename; + + Working_Set *working_set = &models->working_set; + + if (exchange_file_ready(exchange, binding->sys_id, &data, &size, &max)){ + ed_file = working_set_get_file(working_set, binding->app_id, 1).file; + Assert(ed_file); + + filename = exchange_file_filename(exchange, binding->sys_id); + preload_settings = ed_file->preload; + if (data){ + String val = make_string((char*)data, size); + // TODO(allen): reduce to just passing models + file_create_from_string(system, models, ed_file, filename, val); + + if (ed_file->settings.tokens_exist){ + file_first_lex_parallel(system, general, ed_file); + } + + if ((binding->success & SysAppCreateView) && binding->panel != 0){ + view_file_in_panel(cmd, binding->panel, ed_file); + } + + for (View_Iter iter = file_view_iter_init(&models->layout, ed_file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + view_measure_wraps(system, general, iter.view); + view_cursor_move(iter.view, preload_settings.start_line, 0); + } + + app_result.redraw = 1; + } + else{ + if (binding->fail & SysAppCreateNewBuffer){ + file_create_empty(system, models, ed_file, filename); + if (binding->fail & SysAppCreateView){ + view_file_in_panel(cmd, binding->panel, ed_file); + } + } + else{ + table_remove(&models->working_set.table, ed_file->name.source_path); + working_set_free_file(&models->working_set, ed_file); + } + + app_result.redraw = 1; + } + + exchange_free_file(exchange, binding->sys_id); + remove = 1; + } + + if (exchange_file_save_complete(exchange, binding->sys_id, &data, &size, &max, &failed)){ + Assert(remove == 0); + + if (data){ + general_memory_free(general, data); + exchange_clear_file(exchange, binding->sys_id); + } + + Editing_File *file = working_set_get_file(working_set, binding->app_id, 1).file; + if (file){ + file_synchronize_times(system, file, file->name.source_path.str); + } + + exchange_free_file(exchange, binding->sys_id); + remove = 1; + + // if (failed) { TODO(allen): saving error, now what? } + } + + if (remove){ + *binding = vars->sys_app_bindings[--vars->sys_app_count]; + --i; + } + } + } + ProfileEnd(sys_app_bind_processing); + + // NOTE(allen): process as many delayed actions as possible + ProfileStart(delayed_actions); + if (models->delay1.count > 0){ + Working_Set *working_set = &models->working_set; + Mem_Options *mem = &models->mem; + General_Memory *general = &mem->general; + + i32 count = models->delay1.count; + models->delay1.count = 0; + models->delay2.count = 0; + + Delayed_Action *act = models->delay1.acts; + for (i32 i = 0; i < count; ++i, ++act){ + String string = act->string; + Panel *panel = act->panel; + Editing_File *file = act->file; + i32 integer = act->integer; + + // TODO(allen): Paramter checking in each DACT case. + switch (act->type){ + case DACT_TOUCH_FILE: + { + if (file){ + Assert(!file->state.is_dummy); + dll_remove(&file->node); + dll_insert(&models->working_set.used_sentinel, &file->node); + } + }break; + + case DACT_OPEN: + case DACT_OPEN_BACKGROUND: + { + App_Open_File_Result result = {}; + { + String filename = string; + Get_File_Result file; + i32 file_id; + + filename.str[0] = char_to_lower(filename.str[0]); + + result.file = working_set_contains(working_set, filename); + if (result.file == 0){ + result.is_new = 1; + file = working_set_get_available_file(working_set); + if (file.file){ + result.file = file.file; + file_id = exchange_request_file(exchange, filename.str, filename.size); + if (file_id){ + file_init_strings(result.file); + file_set_name(working_set, result.file, filename.str); + file_set_to_loading(result.file); + table_add(&working_set->table, result.file->name.source_path, file.index); + + result.sys_id = file_id; + result.file_index = file.index; + } + else{ + working_set_free_file(working_set, file.file); + file.file = 0; + } + } + } + } + + if (result.is_new){ + if (result.file){ + if (result.sys_id){ + Sys_App_Binding *binding = app_push_file_binding(vars, result.sys_id, result.file_index); + binding->success = (act->type == DACT_OPEN) ? SysAppCreateView : 0; + binding->fail = 0; + binding->panel = panel; + } + else{ + delayed_action_repush(&models->delay2, act); + } + } + } + else{ + if (act->type == DACT_OPEN){ + Assert(result.file); + if (!result.file->state.is_loading){ + view_file_in_panel(cmd, panel, result.file); + } + } + } + }break; + + case DACT_SET_LINE: + { + // TODO(allen): deduplicate + Editing_File *file = 0; + if (panel){ + file = panel->view->file; + } + else if (string.str && string.size > 0){ + file = working_set_lookup_file(working_set, string); + } + if (file){ + if (file->state.is_loading){ + file->preload.start_line = integer; + } + else{ + // TODO(allen): write this case + } + } + }break; + + case DACT_SAVE_AS: + { + // TODO(allen): deduplicate + Editing_File *file = 0; + if (panel){ + file = panel->view->file; + } + else if (string.str && string.size > 0){ + file = working_set_lookup_file(working_set, string); + } + if (file){ + i32 sys_id = file_save_and_set_names(system, exchange, mem, working_set, file, string.str); + if (sys_id){ + app_push_file_binding(vars, sys_id, (i32)(file - working_set->files)); + } + else{ + delayed_action_repush(&models->delay2, act); + } + } + }break; + + case DACT_SAVE: + { + if (!file){ + if (panel){ + View *view = panel->view; + Assert(view); + file = view->file; + } + else{ + file = working_set_lookup_file(working_set, string); + } + } + // TODO(allen): We could handle the case where someone tries to save the same thing + // twice... that would be nice to have under control. + if (file){ + i32 sys_id = file_save(system, exchange, mem, file, file->name.source_path.str); + if (sys_id){ + // TODO(allen): This is fishy! Shouldn't we bind it to a file name instead? This file + // might be killed before we get notified that the saving is done! + app_push_file_binding(vars, sys_id, (i32)(file - working_set->files)); + } + else{ + delayed_action_repush(&models->delay2, act); + } + } + }break; + + case DACT_NEW: + { + Get_File_Result file = working_set_get_available_file(working_set); + file_create_empty(system, models, file.file, string.str); + table_add(&working_set->table, file.file->name.source_path, file.index); + + View *view = panel->view; + + view_set_file(view, file.file, models, system, + models->hooks[hook_open_file], &app_links); + view->map = app_get_map(models, file.file->settings.base_map_id); +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + if (file.file->settings.tokens_exist) + file_first_lex_parallel(system, general, file.file); +#endif + }break; + + case DACT_SWITCH: + { + if (!file && string.str){ + file = working_set_lookup_file(working_set, string); + + if (!file){ + file = working_set_contains(working_set, string); + } + } + + if (file){ + View *view = panel->view; + + view_set_file(view, file, models, system, + models->hooks[hook_open_file], &app_links); + view->map = app_get_map(models, file->settings.base_map_id); + } + }break; + + case DACT_KILL: + { + if (!file && string.str){ + file = working_set_lookup_file(working_set, string); + + if (!file){ + file = working_set_contains(working_set, string); + } + } + + if (file){ + table_remove(&working_set->table, file->name.source_path); + kill_file(system, exchange, models, file, + models->hooks[hook_open_file], &app_links); + } + }break; + + case DACT_TRY_KILL: + { + View *view = 0; + if (panel){ + view = panel->view; + } + else{ + view = (models->layout.panels + models->layout.active_panel)->view; + } + + if (!file && string.str){ + file = working_set_lookup_file(working_set, string); + + if (!file){ + file = working_set_contains(working_set, string); + } + } + + if (file){ + if (buffer_needs_save(file)){ + view_show_interactive(system, view, &models->map_ui, + IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?")); + copy(&view->dest, file->name.live_name); + } + else{ + table_remove(&working_set->table, file->name.source_path); + kill_file(system, exchange, models, file, + models->hooks[hook_open_file], &app_links); + } + } + }break; + } + + if (string.str){ + general_memory_free(general, string.str); + } + } + Swap(models->delay1, models->delay2); + } + + end_temp_memory(param_stack_temp); + ProfileEnd(delayed_actions); + + ProfileStart(resize); + // NOTE(allen): send resize messages to panels that have changed size + { + Panel *panel, *used_panels; + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + i32_Rect prev = panel->prev_inner; + i32_Rect inner = panel->inner; + if (prev.x0 != inner.x0 || prev.y0 != inner.y0 || + prev.x1 != inner.x1 || prev.y1 != inner.y1){ + remeasure_file_view(system, panel->view, panel->inner); + } + panel->prev_inner = inner; + } + } + ProfileEnd(resize); + + ProfileStart(style_change); + // NOTE(allen): send style change messages if the style has changed + if (models->global_font.font_changed){ + models->global_font.font_changed = 0; + + File_Node *node, *used_nodes; + Editing_File *file; + Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font; + float *advance_data = 0; + if (font) advance_data = font->advance_data; + + used_nodes = &models->working_set.used_sentinel; + for (dll_items(node, used_nodes)){ + file = (Editing_File*)node; + file_measure_starts_widths(system, &models->mem.general, &file->state.buffer, advance_data); + } + + Panel *panel, *used_panels; + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + remeasure_file_view(system, panel->view, panel->inner); + } + } + ProfileEnd(style_change); + + ProfileStart(redraw); + if (mouse_panel != models->prev_mouse_panel) app_result.redraw = 1; + if (app_result.redraw){ + begin_render_section(target, system); + + target->clip_top = -1; + draw_push_clip(target, rect_from_target(target)); + + // NOTE(allen): render the panels + Panel *panel, *used_panels; + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + i32_Rect full = panel->full; + i32_Rect inner = panel->inner; + + View *view = panel->view; + Style *style = &models->style; + + b32 active = (panel == cmd->panel); + u32 back_color = style->main.back_color; + draw_rectangle(target, full, back_color); + + draw_push_clip(target, panel->inner); + draw_file_view(system, exchange, view, cmd->view, panel->inner, active, target, &dead_input); + draw_pop_clip(target); + + u32 margin_color; + if (active){ + margin_color = style->main.margin_active_color; + } + else if (panel == mouse_panel){ + margin_color = style->main.margin_hover_color; + } + else{ + margin_color = style->main.margin_color; + } + draw_rectangle(target, i32R(full.x0, full.y0, full.x1, inner.y0), margin_color); + draw_rectangle(target, i32R(full.x0, inner.y1, full.x1, full.y1), margin_color); + draw_rectangle(target, i32R(full.x0, inner.y0, inner.x0, inner.y1), margin_color); + draw_rectangle(target, i32R(inner.x1, inner.y0, full.x1, inner.y1), margin_color); + } + + end_render_section(target, system); + } + ProfileEnd(redraw); + + ProfileStart(get_cursor); + // NOTE(allen): get cursor type + if (mouse_in_edit_area){ + app_result.mouse_cursor_type = APP_MOUSE_CURSOR_ARROW; + } + else if (mouse_in_margin_area){ + if (mouse_on_divider){ + if (mouse_divider_vertical){ + app_result.mouse_cursor_type = APP_MOUSE_CURSOR_LEFTRIGHT; + } + else{ + app_result.mouse_cursor_type = APP_MOUSE_CURSOR_UPDOWN; + } + } + else{ + app_result.mouse_cursor_type = APP_MOUSE_CURSOR_ARROW; + } + } + models->prev_mouse_panel = mouse_panel; + ProfileEnd(get_cursor); + + app_result.lctrl_lalt_is_altgr = models->settings.lctrl_lalt_is_altgr; + *result = app_result; + + // end-of-app_step +} + +external App_Get_Functions_Sig(app_get_functions){ + App_Functions result = {}; + + result.read_command_line = app_read_command_line; + result.init = app_init; + result.step = app_step; + + return(result); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed.h b/test_data/lots_of_files/4ed.h new file mode 100644 index 0000000..c27572f --- /dev/null +++ b/test_data/lots_of_files/4ed.h @@ -0,0 +1,130 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.12.2014 + * + * Application Layer for 4coder + * + */ + +// TOP + +#ifndef FRED_H +#define FRED_H + +struct Application_Memory{ + void *vars_memory; + i32 vars_memory_size; + void *target_memory; + i32 target_memory_size; + void *user_memory; + i32 user_memory_size; +}; + +#define KEY_INPUT_BUFFER_SIZE 4 +#define KEY_INPUT_BUFFER_DSIZE (KEY_INPUT_BUFFER_SIZE << 1) + +struct Key_Input_Data{ + Key_Event_Data press[KEY_INPUT_BUFFER_SIZE]; + Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE]; + i32 press_count; + i32 hold_count; +}; + +struct Key_Summary{ + i32 count; + Key_Event_Data keys[KEY_INPUT_BUFFER_DSIZE]; +}; + +inline Key_Event_Data +get_single_key(Key_Summary *summary, i32 index){ + Assert(index >= 0 && index < summary->count); + Key_Event_Data key; + key = summary->keys[index]; + return key; +} + +struct Input_Summary{ + Mouse_State mouse; + Key_Summary keys; +}; + +struct Command_Line_Parameters{ + char **argv; + int argc; +}; + +struct Plat_Settings{ + char *custom_dll; + b32 custom_dll_is_strict; + + i32 window_w, window_h; + i32 window_x, window_y; + b8 set_window_pos, set_window_size; + b8 maximize_window; +}; + +#define App_Read_Command_Line_Sig(name) \ + i32 name(System_Functions *system, \ + Application_Memory *memory, \ + String current_directory, \ + Plat_Settings *plat_settings, \ + char ***files, i32 **file_count, \ + Command_Line_Parameters clparams \ + ) + +typedef App_Read_Command_Line_Sig(App_Read_Command_Line); + +#define App_Init_Sig(name) void \ +name(System_Functions *system, \ + Render_Target *target, \ + Application_Memory *memory, \ + Exchange *exchange, \ + String clipboard, \ + String current_directory, \ + Custom_API api) + +typedef App_Init_Sig(App_Init); + +enum Application_Mouse_Cursor{ + APP_MOUSE_CURSOR_DEFAULT, + APP_MOUSE_CURSOR_ARROW, + APP_MOUSE_CURSOR_IBEAM, + APP_MOUSE_CURSOR_LEFTRIGHT, + APP_MOUSE_CURSOR_UPDOWN, + // never below this + APP_MOUSE_CURSOR_COUNT +}; + +struct Application_Step_Result{ + Application_Mouse_Cursor mouse_cursor_type; + b32 redraw; + b32 lctrl_lalt_is_altgr; +}; + +#define App_Step_Sig(name) void \ + name(System_Functions *system, \ + Key_Input_Data *input, \ + Mouse_State *mouse, \ + Render_Target *target, \ + Application_Memory *memory, \ + Exchange *exchange, \ + String clipboard, \ + b32 time_step, b32 first_step, b32 force_redraw, \ + Application_Step_Result *result) + +typedef App_Step_Sig(App_Step); + +struct App_Functions{ + App_Read_Command_Line *read_command_line; + App_Init *init; + App_Step *step; +}; + +#define App_Get_Functions_Sig(name) App_Functions name() +typedef App_Get_Functions_Sig(App_Get_Functions); + +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_app_settings.h b/test_data/lots_of_files/4ed_app_settings.h new file mode 100644 index 0000000..c277476 --- /dev/null +++ b/test_data/lots_of_files/4ed_app_settings.h @@ -0,0 +1,67 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 27.01.2016 + * + * Global app level settings definition + * + */ + +// TOP + +struct App_Settings{ + char *user_file; + b32 user_file_is_strict; + + char *init_files[8]; + i32 init_files_count; + i32 init_files_max; + + i32 initial_line; + b32 lctrl_lalt_is_altgr; +}; + +struct Models{ + Mem_Options mem; + App_Settings settings; + + Command_Map map_top; + Command_Map map_file; + Command_Map map_ui; + Command_Map *user_maps; + i32 *map_id_table; + i32 user_map_count; + + Command_Binding prev_command; + + Coroutine *command_coroutine; + u32 command_coroutine_flags[2]; + + Hook_Function *hooks[hook_type_count]; + + i32 *buffer_param_indices; + i32 buffer_param_count, buffer_param_max; + + Font_Set *font_set; + Style_Font global_font; + Style style; + Style_Library styles; + u32 *palette; + i32 palette_size; + + Editing_Layout layout; + Working_Set working_set; + + char hot_dir_base_[256]; + Hot_Directory hot_directory; + + Delay delay1, delay2; + + Panel *prev_mouse_panel; + + Custom_API config_api; + Scroll_Rule_Function *scroll_rule; +}; + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_app_target.cpp b/test_data/lots_of_files/4ed_app_target.cpp new file mode 100644 index 0000000..26d1958 --- /dev/null +++ b/test_data/lots_of_files/4ed_app_target.cpp @@ -0,0 +1,55 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 13.11.2015 + * + * Application layer build target + * + */ + +// TOP + +#include "4ed_config.h" + +#define BUFFER_EXPERIMENT_SCALPEL 0 + +#include "4ed_meta.h" + +#include "4cpp_types.h" +#define FCPP_STRING_IMPLEMENTATION +#include "4coder_string.h" + +#include "4ed_mem.cpp" +#include "4ed_math.cpp" + +#include "4coder_custom.h" +#include "4ed_system.h" +#include "4ed_rendering.h" +#include "4ed.h" + +#include "4ed_internal.h" + +#include "4tech_table.cpp" + +#define FCPP_LEXER_IMPLEMENTATION +#include "4cpp_lexer.h" + +#include "4ed_template.cpp" + +#include "4ed_font_set.cpp" +#include "4ed_rendering_helper.cpp" + +#include "4ed_style.h" +#include "4ed_style.cpp" +#include "4ed_exchange.cpp" +#include "4ed_command.cpp" +#include "4ed_file.cpp" +#include "4ed_gui.cpp" +#include "4ed_layout.cpp" +#include "4ed_delay.cpp" +#include "4ed_app_settings.h" +#include "4ed_file_view.cpp" +#include "4ed.cpp" + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_command.cpp b/test_data/lots_of_files/4ed_command.cpp new file mode 100644 index 0000000..4681ad2 --- /dev/null +++ b/test_data/lots_of_files/4ed_command.cpp @@ -0,0 +1,201 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 19.08.2015 + * + * Command management functions for 4coder + * + */ + +// TOP + +#define Command_Function_Sig(name) void (name)( \ + System_Functions *system, \ + struct Command_Data *command, \ + struct Command_Binding binding) + +typedef Command_Function_Sig(*Command_Function); + +struct Command_Binding{ + Command_Function function; + union{ + Custom_Command_Function *custom; + u64 custom_id; + }; + i64 hash; +}; + +struct Command_Map{ + Command_Map *parent; + Command_Binding vanilla_keyboard_default; + Command_Binding *commands; + i32 count, max; +}; + +internal void command_null(Command_Data *command); + +internal i64 +map_hash(u16 event_code, u8 modifiers){ + i64 result = (event_code << 8) | modifiers; + return result; +} + +internal b32 +map_add(Command_Map *map, u16 event_code, u8 modifiers, + Command_Function function, Custom_Command_Function *custom = 0){ + Assert(map->count * 8 < map->max * 7); + Command_Binding bind; + bind.function = function; + bind.custom = custom; + bind.hash = map_hash(event_code, modifiers); + + i32 max = map->max; + i32 index = bind.hash % max; + Command_Binding entry; + while ((entry = map->commands[index]).function && entry.hash != -1){ + if (entry.hash == bind.hash){ + return 1; + } + index = (index + 1) % max; + } + map->commands[index] = bind; + ++map->count; + return 0; +} + +inline b32 +map_add(Command_Map *map, u16 event_code, u8 modifiers, + Command_Function function, u64 custom_id){ + return (map_add(map, event_code, modifiers, function, (Custom_Command_Function*)custom_id)); +} + +internal b32 +map_find_entry(Command_Map *map, u16 event_code, u8 modifiers, + i32 *index_out){ + i64 hash = map_hash(event_code, modifiers); + i32 max = map->max; + i32 index = hash % map->max; + Command_Binding entry; + while ((entry = map->commands[index]).function){ + if (entry.hash == hash){ + *index_out = index; + return 1; + } + index = (index + 1) % max; + } + return 0; +} + +internal b32 +map_find(Command_Map *map, u16 event_code, u8 modifiers, + Command_Binding *bind_out){ + b32 result; + i32 index; + result = map_find_entry(map, event_code, modifiers, &index); + if (result){ + *bind_out = map->commands[index]; + } + return result; +} + +internal b32 +map_drop(Command_Map *map, u16 event_code, u8 modifiers){ + b32 result; + i32 index; + result = map_find_entry(map, event_code, modifiers, &index); + if (result){ + map->commands[index].function = 0; + map->commands[index].hash = -1; + } + return result; +} + +internal void +map_init(Command_Map *commands, Partition *part, i32 max, Command_Map *parent){ + max = ((max < 6)?(6):(max)); + commands->parent = parent; + commands->commands = push_array(part, Command_Binding, max); + memset(commands->commands, 0, max*sizeof(*commands->commands)); + commands->vanilla_keyboard_default = {}; + commands->max = max; + commands->count = 0; +} + +internal void +map_get_vanilla_keyboard_default(Command_Map *map, u8 command, + Command_Binding *bind_out){ + if (command == MDFR_NONE){ + *bind_out = map->vanilla_keyboard_default; + } +} + +inline u8 +apply_shift_to_code(u8 keycode){ + return !(keycode >= 0x20 && keycode < 0x7F && keycode != ' '); +} + +internal Command_Binding +map_extract(Command_Map *map, Key_Event_Data key){ + Command_Binding bind = {}; + + b32 ctrl = key.modifiers[MDFR_CONTROL_INDEX]; + b32 alt = key.modifiers[MDFR_ALT_INDEX]; + b32 shift = key.modifiers[MDFR_SHIFT_INDEX]; + u16 code; + u8 command = MDFR_NONE; + + //if (key.character_no_caps_lock != 0 && + // key.character_no_caps_lock != ' ') shift = 0; + + if (shift) command |= MDFR_SHIFT; + if (ctrl) command |= MDFR_CTRL; + if (alt) command |= MDFR_ALT; + + code = key.character_no_caps_lock; + if (code == 0){ + code = key.keycode; + map_find(map, code, command, &bind); + } + else{ + if (code != '\n' && code != '\t' && code != ' '){ + command &= ~(MDFR_SHIFT); + } + + map_find(map, code, command, &bind); + if (bind.function == 0){ + map_get_vanilla_keyboard_default(map, command, &bind); + } + } + + return(bind); +} + +internal Command_Binding +map_extract_recursive(Command_Map *map, Key_Event_Data key){ + Command_Binding cmd_bind = {}; + Command_Map *visited_maps[16] = {}; + i32 visited_top = 0; + + while (map){ + cmd_bind = map_extract(map, key); + if (cmd_bind.function == 0){ + if (visited_top < ArrayCount(visited_maps)){ + visited_maps[visited_top++] = map; + map = map->parent; + for (i32 i = 0; i < visited_top; ++i){ + if (map == visited_maps[i]){ + map = 0; + break; + } + } + } + else map = 0; + } + else map = 0; + } + + return(cmd_bind); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_config.h b/test_data/lots_of_files/4ed_config.h new file mode 100644 index 0000000..64697a2 --- /dev/null +++ b/test_data/lots_of_files/4ed_config.h @@ -0,0 +1,52 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 13.11.2014 + * + * Application layer build target + * + */ + +// TOP + +#ifdef FRED_NOT_PACKAGE + +#define FRED_INTERNAL 1 +#define FRED_SLOW 1 + +#define FRED_PRINT_DEBUG 1 +#define FRED_PRINT_DEBUG_FILE_LINE 0 +#define FRED_PROFILING 1 +#define FRED_PROFILING_OS 0 +#define FRED_FULL_ERRORS 0 + +#else + +#define FRED_SLOW 0 +#define FRED_INTERNAL 0 + +#define FRED_PRINT_DEBUG 0 +#define FRED_PRINT_DEBUG_FILE_LINE 0 +#define FRED_PROFILING 0 +#define FRED_PROFILING_OS 0 +#define FRED_FULL_ERRORS 0 + +#endif + +#if FRED_INTERNAL == 0 +#undef FRED_PRINT_DEBUG +#define FRED_PRINT_DEBUG 0 +#undef FRED_PROFILING +#define FRED_PROFILING 0 +#undef FRED_PROFILING_OS +#define FRED_PROFILING_OS 0 +#endif + +#if FRED_PRINT_DEBUG == 0 +#undef FRED_PRINT_DEBUG_FILE_LINE +#define FRED_PRINT_DEBUG_FILE_LINE 0 +#undef FRED_PRINT_DEBUG_FILE_LINE +#define FRED_PROFILING_OS 0 +#endif + +// BOTTOM diff --git a/test_data/lots_of_files/4ed_delay.cpp b/test_data/lots_of_files/4ed_delay.cpp new file mode 100644 index 0000000..c5b0871 --- /dev/null +++ b/test_data/lots_of_files/4ed_delay.cpp @@ -0,0 +1,131 @@ +enum Action_Type{ + DACT_OPEN, + DACT_OPEN_BACKGROUND, + DACT_SET_LINE, + DACT_SAVE_AS, + DACT_SAVE, + DACT_NEW, + DACT_SWITCH, + DACT_TRY_KILL, + DACT_KILL, + DACT_TOUCH_FILE, +}; + +struct Delayed_Action{ + Action_Type type; + String string; + Panel* panel; + Editing_File* file; + i32 integer; +}; + +struct Delay{ + General_Memory* general; + Delayed_Action* acts; + i32 count; + i32 max; +}; + +internal String +str_alloc_copy(General_Memory *general, String str){ + String result; + result.memory_size = str.memory_size + 1; + result.size = str.size; + result.str = (char*)general_memory_allocate(general, result.memory_size, 0); + memcpy(result.str, str.str, str.size); + result.str[result.size] = 0; + return(result);} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type){ + Delayed_Action *result; + if (delay->count == delay->max){ + delay->max *= 2; + delay->acts = (Delayed_Action*)general_memory_reallocate(delay->general, delay->acts, delay->count*sizeof(Delayed_Action), delay->max*sizeof(Delayed_Action), 0); + } + result = delay->acts + delay->count++; + *result = {}; + result->type = type; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, String string){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->string = str_alloc_copy(delay->general, string); + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, Panel* panel){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->panel = panel; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, Editing_File* file){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->file = file; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, Editing_File* file, Panel* panel){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->file = file; + result->panel = panel; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, String string, Panel* panel){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->string = str_alloc_copy(delay->general, string); + result->panel = panel; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, String string, Editing_File* file){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->string = str_alloc_copy(delay->general, string); + result->file = file; + return(result); +} + +inline Delayed_Action* +delayed_action_(Delay *delay, Action_Type type, Panel* panel, i32 integer){ + Delayed_Action *result; + result = delayed_action_(delay, type); + result->panel = panel; + result->integer = integer; + return(result); +} + +inline Delayed_Action* +delayed_action_repush(Delay *delay, Delayed_Action *act){ + Delayed_Action *new_act = delayed_action_(delay, (Action_Type)0); + *new_act = *act; + if (act->string.str){ + new_act->string = str_alloc_copy(delay->general, act->string); + } + return(new_act); +} + +#define delayed_open(delay, ...) delayed_action_(delay, DACT_OPEN, __VA_ARGS__) +#define delayed_open_background(delay, ...) delayed_action_(delay, DACT_OPEN_BACKGROUND, __VA_ARGS__) +#define delayed_set_line(delay, ...) delayed_action_(delay, DACT_SET_LINE, __VA_ARGS__) +#define delayed_save_as(delay, ...) delayed_action_(delay, DACT_SAVE_AS, __VA_ARGS__) +#define delayed_save(delay, ...) delayed_action_(delay, DACT_SAVE, __VA_ARGS__) +#define delayed_new(delay, ...) delayed_action_(delay, DACT_NEW, __VA_ARGS__) +#define delayed_switch(delay, ...) delayed_action_(delay, DACT_SWITCH, __VA_ARGS__) +#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, __VA_ARGS__) +#define delayed_kill(delay, ...) delayed_action_(delay, DACT_KILL, __VA_ARGS__) +#define delayed_touch_file(delay, ...) delayed_action_(delay, DACT_TOUCH_FILE, __VA_ARGS__) diff --git a/test_data/lots_of_files/4ed_dll_reader.cpp b/test_data/lots_of_files/4ed_dll_reader.cpp new file mode 100644 index 0000000..ea4d638 --- /dev/null +++ b/test_data/lots_of_files/4ed_dll_reader.cpp @@ -0,0 +1,378 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 20.11.2015 + * + * DLL loader declarations for 4coder + * + */ + +// TOP + +// TODO(allen): +// Check the relocation table, if it contains anything that +// is platform specific generate an error to avoid calling +// into invalid code. + +i32 +dll_compare(char *a, char *b, i32 len){ + i32 result; + char *e; + + result = 0; + e = a + len; + for (;a < e && *a == *b; ++a, ++b); + if (a < e){ + if (*a < *b) result = -1; + else result = 1; + } + + return(result); +} + +enum DLL_Error{ + dll_err_too_small_for_header = 1, + dll_err_wrong_MZ_signature, + dll_err_wrong_DOS_error, + dll_err_wrong_PE_signature, + dll_err_unrecognized_bit_signature, +}; + +b32 +dll_parse_headers(Data file, DLL_Data *dll, i32 *error){ + b32 result; + i32 pe_offset; + i32 read_pos; + + result = 1; + if (file.size <= sizeof(DOS_Header) + DOS_error_size){ + if (error) *error = dll_err_too_small_for_header; + result = 0; + goto dll_parse_end; + } + + dll->dos_header = (DOS_Header*)file.data; + + if (dll_compare(dll->dos_header->signature, "MZ", 2) != 0){ + if (error) *error = dll_err_wrong_MZ_signature; + result = 0; + goto dll_parse_end; + } + + if (file.size <= DOS_error_offset + DOS_error_size){ + if (error) *error = dll_err_too_small_for_header; + result = 0; + goto dll_parse_end; + } + + if (dll_compare((char*)(file.data + DOS_error_offset), DOS_error_message, + sizeof(DOS_error_message) - 1) != 0){ + if (error) *error = dll_err_wrong_DOS_error; + result = 0; + goto dll_parse_end; + } + + pe_offset = dll->dos_header->e_lfanew; + read_pos = pe_offset; + + if (file.size <= read_pos + PE_header_size){ + if (error) *error = dll_err_too_small_for_header; + result = 0; + goto dll_parse_end; + } + + if (dll_compare((char*)(file.data + read_pos), + PE_header, PE_header_size) != 0){ + if (error) *error = dll_err_wrong_PE_signature; + result = 0; + goto dll_parse_end; + } + + read_pos += PE_header_size; + + if (file.size <= read_pos + sizeof(COFF_Header)){ + if (error) *error = dll_err_too_small_for_header; + result = 0; + goto dll_parse_end; + } + + dll->coff_header = (COFF_Header*)(file.data + read_pos); + read_pos += sizeof(COFF_Header); + + if (file.size <= read_pos + dll->coff_header->size_of_optional_header){ + if (error) *error = dll_err_too_small_for_header; + result = 0; + goto dll_parse_end; + } + + dll->opt_header_32 = (PE_Opt_Header_32Bit*)(file.data + read_pos); + dll->opt_header_64 = (PE_Opt_Header_64Bit*)(file.data + read_pos); + read_pos += dll->coff_header->size_of_optional_header; + + if (dll->opt_header_32->signature != bitsig_32bit && + dll->opt_header_32->signature != bitsig_64bit){ + if (error) *error = dll_err_unrecognized_bit_signature; + result = 0; + goto dll_parse_end; + } + + if (dll->opt_header_32->signature == bitsig_32bit) dll->is_64bit = 0; + else dll->is_64bit = 1; + + dll->section_defs = (PE_Section_Definition*)(file.data + read_pos); + +dll_parse_end: + return(result); +} + +i32 +dll_total_loaded_size(DLL_Data *dll){ + COFF_Header *coff_header; + PE_Section_Definition *section_def; + i32 result, section_end, i; + + coff_header = dll->coff_header; + section_def = dll->section_defs; + result = 0; + + for (i = 0; i < coff_header->number_of_sections; ++i, ++section_def){ + section_end = section_def->loaded_location + section_def->loaded_size; + if (section_end > result){ + result = section_end; + } + } + + return(result); +} + +b32 +dll_perform_reloc(DLL_Loaded *loaded){ + Data img; + byte *base; + Relocation_Block_Header *header; + Relocation_Block_Entry *entry; + Data_Directory *data_directory; + u32 cursor; + u32 bytes_in_table; + u32 block_end; + u32 type; + u32 offset; + b32 result; + b32 highadj_stage; + + u64 dif64; + + result = 1; + img = loaded->img; + if (loaded->is_64bit){ + data_directory = loaded->opt_header_64->data_directory; + dif64 = ((u64)img.data - (u64)loaded->opt_header_64->image_base); + } + else{ + data_directory = loaded->opt_header_32->data_directory; + dif64 = ((u64)img.data - (u64)loaded->opt_header_32->image_base); + } + data_directory += image_dir_base_reloc_table; + base = img.data + data_directory->virtual_address; + bytes_in_table = data_directory->size; + + highadj_stage = 1; + + + for (cursor = 0; cursor < bytes_in_table;){ + header = (Relocation_Block_Header*)(base + cursor); + block_end = cursor + header->block_size; + cursor += sizeof(Relocation_Block_Header); + + for (;cursor < block_end;){ + entry = (Relocation_Block_Entry*)(base + cursor); + cursor += sizeof(Relocation_Block_Entry); + + type = (u32)(entry->entry & reloc_entry_type_mask) >> reloc_entry_type_shift; + offset = (u32)(entry->entry & reloc_entry_offset_mask) + header->page_base_offset; + + switch (type){ + case image_base_absolute: break; + + case image_base_high: + case image_base_low: + case image_base_highlow: + case image_base_highadj: + case image_base_arm_mov32a: + case image_base_arm_mov32t: + case image_base_mips_jmpaddr16: + result = 0; + goto dll_reloc_end; + + case image_base_dir64: + *(u64*)(img.data + offset) += dif64; + break; + } + } + } + +dll_reloc_end: + return(result); +} + +b32 +dll_load_sections(Data img, DLL_Loaded *loaded, + Data file, DLL_Data *dll){ + COFF_Header *coff_header; + PE_Section_Definition *section_def; + u32 header_size; + u32 size; + u32 i; + + coff_header = dll->coff_header; + section_def = dll->section_defs; + + header_size = + (u32)((byte*)(section_def + coff_header->number_of_sections) - file.data); + + memcpy(img.data, file.data, header_size); + memset(img.data + header_size, 0, img.size - header_size); + + for (i = 0; i < coff_header->number_of_sections; ++i, ++section_def){ + size = section_def->loaded_size; + if (size > section_def->disk_size) + size = section_def->disk_size; + + memcpy(img.data + section_def->loaded_location, + file.data + section_def->disk_location, + size); + + if (dll_compare(section_def->name, ".text", 5) == 0){ + loaded->text_start = section_def->loaded_location; + loaded->text_size = section_def->loaded_size; + } + } + + return(1); +} + +void +dll_load(Data img, DLL_Loaded *loaded, Data file, DLL_Data *dll){ + Data_Directory *export_dir; + + dll_load_sections(img, loaded, file, dll); + loaded->img = img; + + loaded->dos_header = (DOS_Header*)((byte*)img.data + ((byte*)dll->dos_header - file.data)); + loaded->coff_header = (COFF_Header*)((byte*)img.data + ((byte*)dll->coff_header - file.data)); + + loaded->opt_header_32 = (PE_Opt_Header_32Bit*) + ((byte*)img.data + ((byte*)dll->opt_header_32 - file.data)); + loaded->opt_header_64 = (PE_Opt_Header_64Bit*) + ((byte*)img.data + ((byte*)dll->opt_header_64 - file.data)); + + loaded->section_defs = (PE_Section_Definition*) + ((byte*)img.data + ((byte*)dll->section_defs - file.data)); + + loaded->is_64bit = dll->is_64bit; + + if (dll->is_64bit){ + export_dir = dll->opt_header_64->data_directory; + } + else{ + export_dir = dll->opt_header_32->data_directory; + } + export_dir += image_dir_entry_export; + loaded->export_start = export_dir->virtual_address; + + dll_perform_reloc(loaded); +} + +void* +dll_load_function(DLL_Loaded *dll, char *func_name, i32 size){ + Data img; + DLL_Export_Directory_Table *export_dir; + DLL_Export_Address *address_ptr; + DLL_Export_Name *name_ptr; + void *result; + u32 count, i; + u32 result_offset; + u32 ordinal; + + img = dll->img; + export_dir = (DLL_Export_Directory_Table*)(img.data + dll->export_start); + + count = export_dir->number_of_name_pointers; + name_ptr = (DLL_Export_Name*)(img.data + export_dir->name_pointer_offset); + + result = 0; + for (i = 0; i < count; ++i, ++name_ptr){ + if (dll_compare((char*)img.data + name_ptr->name_offset, + func_name, size) == 0){ + ordinal = ((u16*)(img.data + export_dir->ordinal_offset))[i]; +#if 0 + // NOTE(allen): The MS docs say to do this, but + // it appears to just be downright incorrect. + ordinal -= export_dir->ordinal_base; +#endif + address_ptr = (DLL_Export_Address*)(img.data + export_dir->address_offset); + address_ptr += ordinal; + result_offset = address_ptr->export_offset; + result = (img.data + result_offset); + break; + } + } + + return(result); +} + +#define MachineCase(x) case x: result = #x; *len = sizeof(#x) - 1; break + +char* +dll_machine_type_str(u16 machine, i32 *len){ + char *result; + i32 extra; + + if (!len) len = &extra; + result = 0; + + switch (machine){ + MachineCase(intel_i386); + MachineCase(intel_i860); + + MachineCase(mips_r3000); + MachineCase(mips_little_endian); + MachineCase(mips_r10000); + + MachineCase(old_alpha_axp); + MachineCase(alpha_axp); + + MachineCase(hitachi_sh3); + MachineCase(hitachi_sh3_dsp); + MachineCase(hitachi_sh4); + MachineCase(hitachi_sh5); + + MachineCase(arm_little_endian); + MachineCase(thumb); + + MachineCase(matsushita_am33); + MachineCase(power_pc_little_endian); + MachineCase(power_pc_with_floating); + + MachineCase(intel_ia64); + MachineCase(mips16); + MachineCase(motorola_68000_series); + + MachineCase(alpha_axp_64_bit); + + MachineCase(mips_with_fpu); + MachineCase(mips16_with_fpu); + MachineCase(eft_byte_code); + + MachineCase(amd_amd64); + MachineCase(mitsubishi_m32r_little_endian); + MachineCase(clr_pure_msil); + } + + return(result); +} + +#undef MachineCase + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_dll_reader.h b/test_data/lots_of_files/4ed_dll_reader.h new file mode 100644 index 0000000..1ebd68d --- /dev/null +++ b/test_data/lots_of_files/4ed_dll_reader.h @@ -0,0 +1,441 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 20.11.2015 + * + * DLL loader declarations for 4coder + * + */ + +// TOP + +struct DOS_Header { + char signature[2]; + i16 lastsize; + i16 nblocks; + i16 nreloc; + i16 hdrsize; + i16 minalloc; + i16 maxalloc; + i16 ss; + i16 sp; + i16 checksum; + i16 ip; + i16 cs; + i16 relocpos; + i16 noverlay; + i16 reserved1[4]; + i16 oem_id; + i16 oem_info; + i16 reserved2[10]; + i32 e_lfanew; +}; + +enum Target_Machine_Code{ + intel_i386 = 0x14C, + intel_i860 = 0x14D, + + mips_r3000 = 0x162, + mips_little_endian = 0x166, + mips_r10000 = 0x168, + + old_alpha_axp = 0x183, + alpha_axp = 0x184, + + hitachi_sh3 = 0x1a2, + hitachi_sh3_dsp = 0x1a3, + hitachi_sh4 = 0x1a6, + hitachi_sh5 = 0x1a8, + + arm_little_endian = 0x1c0, + thumb = 0x1c2, + + matsushita_am33 = 0x1d3, + power_pc_little_endian = 0x1f0, + power_pc_with_floating = 0x1f1, + + intel_ia64 = 0x200, + mips16 = 0x266, + motorola_68000_series = 0x268, + + alpha_axp_64_bit = 0x284, + + mips_with_fpu = 0x366, + mips16_with_fpu = 0x466, + eft_byte_code = 0xebc, + + amd_amd64 = 0x8664, + mitsubishi_m32r_little_endian = 0x9041, + clr_pure_msil = 0xc0ee +}; + +#define file_is_exe 0x2 +#define file_is_non_reloctable 0x200 +#define file_is_dll 0x2000 + +struct COFF_Header{ + u16 machine; + u16 number_of_sections; + u32 time_date_stamp; + u32 pointer_to_symbol_table; + u32 number_of_symbols; + u16 size_of_optional_header; + u16 characteristics; +}; + +struct Data_Directory{ + u32 virtual_address; + u32 size; +}; + +// This version is untested +struct PE_Opt_Header_32Bit{ + // Universal Portion + i16 signature; + i8 major_linker_version; + i8 minor_linker_version; + i32 size_of_code; + i32 size_of_initialized_data; + i32 size_of_uninitialized_data; + i32 address_of_entry_point; + i32 base_of_code; + i32 base_of_data; + + // Windows Portion + i32 image_base; + i32 section_alignment; + i32 file_alignment; + i16 major_OS_version; + i16 minor_OS_version; + i16 major_image_version; + i16 minor_image_version; + i16 major_subsystem_version; + i16 minor_subsystem_version; + i32 reserved; + i32 size_of_image; + i32 size_of_headers; + i32 checksum; + i16 subsystem; + i16 DLL_characteristics; + i32 size_of_stack_reserve; + i32 size_of_stack_commit; + i32 size_of_heap_reserve; + i32 size_of_heap_commit; + i32 loader_flags; + i32 number_of_rva_and_sizes; + Data_Directory data_directory[16]; +}; + +struct PE_Opt_Header_64Bit{ + // Universal Portion + u16 signature; + u8 major_linker_version; + u8 minor_linker_version; + u32 size_of_code; + u32 size_of_initialized_data; + u32 size_of_uninitialized_data; + u32 address_of_entry_point; + u32 base_of_code; + + // Windows Portion + u64 image_base; + u32 section_alignment; + u32 file_alignment; + u16 major_OS_version; + u16 minor_OS_version; + u16 major_image_version; + u16 minor_image_version; + u16 major_subsystem_version; + u16 minor_subsystem_version; + u32 reserved; + u32 size_of_image; + u32 size_of_headers; + u32 checksum; + u16 subsystem; + u16 DLL_characteristics; + u64 size_of_stack_reserve; + u64 size_of_stack_commit; + u64 size_of_heap_reserve; + u64 size_of_heap_commit; + u32 loader_flags; + u32 number_of_rva_and_sizes; + Data_Directory data_directory[16]; +}; + +#define bitsig_32bit 267 +#define bitsig_64bit 523 + +#define image_dir_entry_export 0 +#define image_dir_entry_import 1 +#define image_dir_entry_resource 2 +#define image_dir_base_reloc_table 5 +#define image_dir_entry_bound_import 11 + +struct PE_Section_Definition{ + char name[8]; + u32 loaded_size; + u32 loaded_location; + u32 disk_size; + u32 disk_location; + u32 disk_relocs; + u32 reserved1; + u16 number_of_relocs; + u16 reserved2; + u32 flags; +}; + +#define image_scn_type_no_pad 0x00000008 +#define image_scn_cnt_code 0x00000020 +#define image_scn_cnt_initialized_data 0x00000040 +#define image_scn_cnt_uninitialized_data 0x00000080 +#define image_scn_lnk_other 0x00000100 +#define image_scn_lnk_info 0x00000200 +#define image_scn_lnk_remove 0x00000800 +#define image_scn_lnk_comdat 0x00001000 +#define image_scn_no_defer_spec_exc 0x00004000 +#define image_scn_gprel 0x00008000 +#define image_scn_mem_fardata 0x00008000 +#define image_scn_mem_purgeable 0x00020000 +#define image_scn_mem_16BIT 0x00020000 +#define image_scn_mem_locked 0x00040000 +#define image_scn_mem_preload 0x00080000 + +#define image_scn_align_1bytes 0x00100000 +#define image_scn_align_2bytes 0x00200000 +#define image_scn_align_4bytes 0x00300000 +#define image_scn_align_8bytes 0x00400000 +#define image_scn_align_16bytes 0x00500000 +#define image_scn_align_32bytes 0x00600000 +#define image_scn_align_64bytes 0x00700000 +#define image_scn_align_128bytes 0x00800000 +#define image_scn_align_256bytes 0x00900000 +#define image_scn_align_512bytes 0x00A00000 +#define image_scn_align_1024bytes 0x00B00000 +#define image_scn_align_2048bytes 0x00C00000 +#define image_scn_align_4096bytes 0x00D00000 +#define image_scn_align_8192bytes 0x00E00000 +#define image_scn_align_mask 0x00F00000 + +#define image_scn_lnk_nreloc_ovfl 0x01000000 +#define image_scn_mem_discardable 0x02000000 +#define image_scn_mem_not_cached 0x04000000 +#define image_scn_mem_not_paged 0x08000000 +#define image_scn_mem_shared 0x10000000 +#define image_scn_mem_execute 0x20000000 +#define image_scn_mem_read 0x40000000 +#define image_scn_mem_write 0x80000000 + +#pragma pack(push, 1) +struct COFF_Relocation{ + u32 virtual_address; + u32 symbol_table_index; + u16 type; +}; +#pragma pack(pop) + +enum Image_Rel_Amd64{ + image_rel_amd64_absolute = 0x00, + image_rel_amd64_addr64 = 0x01, + image_rel_amd64_addr32 = 0x02, + image_rel_amd64_addr32nb = 0x03, + image_rel_amd64_rel32 = 0x04, + image_rel_amd64_rel32_1 = 0x05, + image_rel_amd64_rel32_2 = 0x06, + image_rel_amd64_rel32_3 = 0x07, + image_rel_amd64_rel32_4 = 0x08, + image_rel_amd64_rel32_5 = 0x09, + image_rel_amd64_section = 0x0A, + image_rel_amd64_secrel = 0x0B, + image_rel_amd64_secrel7 = 0x0C, + image_rel_amd64_token = 0x0D, + image_rel_amd64_srel32 = 0x0E, + image_rel_amd64_pair = 0x0F, + image_rel_amd64_sspan32 = 0x10 +}; + +enum Image_Rel_Arm{ + image_rel_arm_absolute = 0x0, + image_rel_arm_addr32 = 0x1, + image_rel_arm_addr32nb = 0x2, + image_rel_arm_branch24 = 0x3, + image_rel_arm_branch11 = 0x4, + image_rel_arm_token = 0x5, + image_rel_arm_blx24 = 0x6, + image_rel_arm_blx11 = 0x7, + image_rel_arm_section = 0x8, + image_rel_arm_secrel = 0x9, + image_rel_arm_mov32a = 0xA, + image_rel_arm_mov32t = 0xB, + image_rel_arm_branch20t = 0xC, + image_rel_arm_branch24t = 0xD, + image_rel_arm_blx32t = 0xE +}; + +enum Image_Rel_Arm64{ + image_rel_arm64_absolute = 0x0, + image_rel_arm64_addr32 = 0x1, + image_rel_arm64_addr32nb = 0x2, + image_rel_arm64_branch26 = 0x3, + image_rel_arm64_pagebase_rel21 = 0x4, + image_rel_arm64_rel21 = 0x5, + image_rel_arm64_pageoffset_12a = 0x6, + image_rel_arm64_pageoffset_12l = 0x7, + image_rel_arm64_secrel = 0x8, + image_rel_arm64_secrel_low12a = 0x9, + image_rel_arm64_secrel_high12a = 0xA, + image_rel_arm64_secrel_low12l = 0xB, + image_rel_arm64_token = 0xC, + image_rel_arm64_section = 0xD, + image_rel_arm64_addr64 = 0xE +}; + +// NOTE(allen): +// skipped Hitachi SuperH +// skiiped IBM PowerPC + +enum Image_Rel_i386{ + image_rel_i386_absolute = 0x0, + image_rel_i386_dir16 = 0x1, + image_rel_i386_rel16 = 0x2, + image_rel_i386_dir32 = 0x3, + image_rel_i386_dir32nb = 0x4, + image_rel_i386_seg12 = 0x5, + image_rel_i386_section = 0x6, + image_rel_i386_secrel = 0x7, + image_rel_i386_token = 0x8, + image_rel_i386_secrel7 = 0x9, + image_rel_i386_rel32 = 0xA +}; + +// NOTE(allen): +// skipped ia64 +// skipped MIPS +// skiiped Mitsubishi + +struct Relocation_Block_Header{ + u32 page_base_offset; + u32 block_size; +}; + +#define reloc_entry_type_mask 0xF000 +#define reloc_entry_type_shift 12 +#define reloc_entry_offset_mask 0x0FFF + +struct Relocation_Block_Entry{ + u16 entry; +}; + +enum DLL_Relocation_Type{ + image_base_absolute, + // nothing + + image_base_high, + // add high 16 bits of diff to 16 bits at offset + + image_base_low, + // add low 16 bits of diff to 16 bits at offset + + image_base_highlow, + // adds all 32 bits to 32 bits at offset + + image_base_highadj, + // consumes two slots: high 16 bits at location, low 16 bits at next location + + image_base_arm_mov32a, + // mips: jump instruction; arm: MOVW+MOVT + + image_base_reserved1, + + image_base_arm_mov32t, + // MOVW+MOVT in Thumb mode + + image_base_reserved2, + + image_base_mips_jmpaddr16, + // mips16 jump instruction + + image_base_dir64 + // adds to 64 bits field +}; + +struct DLL_Data{ + DOS_Header *dos_header; + COFF_Header *coff_header; + PE_Opt_Header_32Bit *opt_header_32; + PE_Opt_Header_64Bit *opt_header_64; + PE_Section_Definition *section_defs; + b32 is_64bit; +}; + +struct DLL_Loaded{ + DOS_Header *dos_header; + COFF_Header *coff_header; + PE_Opt_Header_32Bit *opt_header_32; + PE_Opt_Header_64Bit *opt_header_64; + PE_Section_Definition *section_defs; + b32 is_64bit; + + Data img; + u32 export_start; + u32 text_start; + u32 text_size; +}; + +struct DLL_Export_Directory_Table{ + u32 export_flags; + u32 time_date_stamp; + u16 major_version; + u16 minor_version; + u32 name_offset; + u32 ordinal_base; + u32 number_of_addresses; + u32 number_of_name_pointers; + u32 address_offset; + u32 name_pointer_offset; + u32 ordinal_offset; +}; + +struct DLL_Export_Address{ + u32 export_offset; +}; + +struct DLL_Export_Name{ + u32 name_offset; +}; + +struct DLL_Export_Ordinal{ + u16 ordinal; +}; + +struct DLL_Debug_Entry{ + u32 characteristics; + u32 time_date_stamp; + u16 major_version; + u16 minor_version; + u32 type; + u32 size_of_data; + u32 offset_of_data; + u32 disk_offset_of_data; +} thingy; + +enum DLL_Debug_Type{ + img_dbg_type_unknown, + img_dbg_type_coff, + img_dbg_type_codeview, + img_dbg_type_fpo, + img_dbg_type_misc, + img_dbg_type_exception, + img_dbg_type_fixup, + img_dbg_type_omap_to_src, + img_dbg_type_omap_from_src +}; + +char DOS_error_message[] = "This program cannot be run in DOS mode."; +i32 DOS_error_offset = 0x4E; +i32 DOS_error_size = sizeof(DOS_error_message) - 1; + +char PE_header[] = {'P', 'E', 0, 0}; +i32 PE_header_size = 4; + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_exchange.cpp b/test_data/lots_of_files/4ed_exchange.cpp new file mode 100644 index 0000000..7908cac --- /dev/null +++ b/test_data/lots_of_files/4ed_exchange.cpp @@ -0,0 +1,234 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 9.12.2015 + * + * Exchange stuff + * + */ + +// TOP + +internal void +ex__file_insert(File_Slot *pos, File_Slot *file){ + pos->next->prev = file; + file->next = pos->next; + pos->next = file; + file->prev = pos; +} + +internal void +ex__file_remove(File_Slot *file){ + file->next->prev = file->prev; + file->prev->next = file->next; +} + +internal void +ex__check_file(File_Slot *pos){ + File_Slot *file = pos; + + Assert(pos == pos->next->prev); + + for (pos = pos->next; + file != pos; + pos = pos->next){ + Assert(pos == pos->next->prev); + } +} + +internal void +ex__check(File_Exchange *file_exchange){ + ex__check_file(&file_exchange->available); + ex__check_file(&file_exchange->active); + ex__check_file(&file_exchange->free_list); +} + +internal void +ex__clear(File_Slot *file){ + file->data = 0; + file->size = 0; + file->max = 0; + file->flags = 0; +} + +internal File_Slot* +ex__get_file(Exchange *exchange){ + File_Exchange *files = &exchange->file; + File_Slot *file; + + ++files->num_active; + + file = files->available.next; + ex__file_remove(file); + ex__clear(file); + ex__file_insert(&files->active, file); + ex__check(files); + + return file; +} + +internal void +ex__set_filename(File_Slot *file, char *filename, int len){ + memcpy(file->filename, filename, len); + file->filename[len] = 0; + file->filename_len = len; +} + +internal i32 +exchange_request_file(Exchange *exchange, char *filename, int len){ + File_Exchange *files = &exchange->file; + i32 result = 0; + + if (len+1 < FileNameMax){ + if (files->num_active < files->max){ + File_Slot *file = ex__get_file(exchange); + ex__set_filename(file, filename, len); + + file->flags |= FEx_Request; + result = (int)(file - files->files) + 1; + } + } + + return result; +} + +internal b32 +exchange_file_ready(Exchange *exchange, i32 file_id, byte **data, int *size, int *max){ + File_Exchange *files = &exchange->file; + b32 result = 0; + + if (file_id > 0 && file_id <= files->max){ + File_Slot *file = files->files + file_id - 1; + if (file->flags & FEx_Ready){ + *data = file->data; + *size = file->size; + *max = file->max; + result = 1; + } + if (file->flags & FEx_Not_Exist){ + *data = 0; + *size = 0; + *max = 0; + result = 1; + } + } + + return result; +} + +internal b32 +exchange_file_does_not_exist(Exchange *exchange, i32 file_id){ + File_Exchange *files = &exchange->file; + b32 result = 1; + File_Slot *slot; + + if (file_id > 0 && file_id <= files->max){ + slot = files->files + file_id - 1; + if (!(slot->flags & FEx_Not_Exist)){ + result = 0; + } + } + + return result; +} + +internal i32 +exchange_save_file(Exchange *exchange, char *filename, int len, + byte *data, int size, int max){ + File_Exchange *files = &exchange->file; + i32 result = 0; + + if (len+1 < FileNameMax){ + if (files->num_active < files->max){ + File_Slot *file = ex__get_file(exchange); + ex__set_filename(file, filename, len); + + file->flags |= FEx_Save; + file->data = data; + file->size = size; + file->max = max; + + result = (int)(file - files->files) + 1; + } + } + + return result; +} + +internal b32 +exchange_file_save_complete(Exchange *exchange, i32 file_id, byte **data, int *size, int *max, int *failed){ + File_Exchange *files = &exchange->file; + b32 result = 0; + + if (file_id > 0 && file_id <= files->max){ + File_Slot *file = files->files + file_id - 1; + if (file->flags & FEx_Save_Complete || file->flags & FEx_Save_Failed){ + *data = file->data; + *size = file->size; + *max = file->max; + result = 1; + + *failed = (file->flags & FEx_Save_Complete)?(1):(0); + } + } + + return result; +} + +internal char* +exchange_file_filename(Exchange *exchange, i32 file_id, i32 *size = 0){ + File_Exchange *files = &exchange->file; + char *result = 0; + + if (file_id > 0 && file_id <= files->max){ + File_Slot *file = files->files + file_id - 1; + result = file->filename; + if (size) *size = file->filename_len; + } + + return result; +} + +internal void +exchange_free_file(Exchange *exchange, i32 file_id){ + File_Exchange *files = &exchange->file; + + if (file_id > 0 && file_id <= files->max){ + File_Slot *file = files->files + file_id - 1; + ex__file_remove(file); + ex__file_insert(&files->free_list, file); + ex__check(files); + } +} + +internal void +exchange_clear_file(Exchange *exchange, i32 file_id){ + File_Exchange *files = &exchange->file; + + if (file_id > 0 && file_id <= files->max){ + File_Slot *file = files->files + file_id - 1; + ex__clear(file); + } +} + +internal b32 +queue_job_is_pending(Work_Queue *queue, u32 job_id){ + b32 result; + u32 job_index; + Full_Job_Data *full_job; + + job_index = job_id % QUEUE_WRAP; + full_job = queue->jobs + job_index; + + Assert(full_job->id == job_id); + + result = 0; + if (full_job->running_thread != 0){ + result = 1; + } + + return(result); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_file.cpp b/test_data/lots_of_files/4ed_file.cpp new file mode 100644 index 0000000..bb474a7 --- /dev/null +++ b/test_data/lots_of_files/4ed_file.cpp @@ -0,0 +1,530 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 20.02.2016 + * + * File editing view for 4coder + * + */ + +// TOP + +#include "buffer/4coder_shared.cpp" + +#if BUFFER_EXPERIMENT_SCALPEL == 0 +#include "buffer/4coder_golden_array.cpp" +#define Buffer_Type Buffer +#elif BUFFER_EXPERIMENT_SCALPEL == 1 +#include "buffer/4coder_gap_buffer.cpp" +#define Buffer_Type Gap_Buffer +#elif BUFFER_EXPERIMENT_SCALPEL == 2 +#include "buffer/4coder_multi_gap_buffer.cpp" +#define Buffer_Type Multi_Gap_Buffer +#else +#include "buffer/4coder_rope_buffer.cpp" +#define Buffer_Type Rope_Buffer +#endif + +#include "buffer/4coder_buffer_abstract.cpp" + +enum Edit_Type{ + ED_NORMAL, + ED_REVERSE_NORMAL, + ED_UNDO, + ED_REDO, +}; + +struct Edit_Step{ + Edit_Type type; + union{ + struct{ + b32 can_merge; + Buffer_Edit edit; + i32 pre_pos; + i32 post_pos; + i32 next_block, prev_block; + }; + struct{ + i32 first_child; + i32 inverse_first_child; + i32 inverse_child_count; + i32 special_type; + }; + }; + i32 child_count; +}; + +struct Edit_Stack{ + u8 *strings; + i32 size, max; + + Edit_Step *edits; + i32 edit_count, edit_max; +}; + +struct Small_Edit_Stack{ + u8 *strings; + i32 size, max; + + Buffer_Edit *edits; + i32 edit_count, edit_max; +}; + +struct Undo_Data{ + Edit_Stack undo; + Edit_Stack redo; + Edit_Stack history; + Small_Edit_Stack children; + + i32 history_block_count, history_head_block; + i32 edit_history_cursor; + b32 current_block_normal; +}; + +struct Text_Effect{ + i32 start, end; + u32 color; + i32 tick_down, tick_max; +}; + +// NOTE(allen): The Editing_File struct is now divided into two +// parts. Variables in the Settings part can be set even when the +// file is still streaming in, and all operations except for the +// initial allocation of the file. +struct Editing_File_Settings{ + i32 base_map_id; + i32 dos_write_mode; + b32 unwrapped_lines; + b8 tokens_exist; + b8 is_initialized; + b8 unimportant; + b8 read_only; +}; + +// NOTE(allen): This part of the Editing_File is cleared whenever +// the contents of the file is set. +struct Editing_File_State{ + b32 is_dummy; + b32 is_loading; + + i16 font_id; + Buffer_Type buffer; + + i32 cursor_pos; + + Undo_Data undo; + + Cpp_Token_Stack token_stack; + Cpp_Token_Stack swap_stack; + u32 lex_job; + b32 tokens_complete; + b32 still_lexing; + + Text_Effect paste_effect; + + u64 last_4ed_write_time; + u64 last_4ed_edit_time; + u64 last_sys_write_time; +}; + +struct Editing_File_Preload{ + i32 start_line; +}; + +struct Editing_File_Name{ + char live_name_[256]; + String live_name; + + char source_path_[256]; + char extension_[16]; + String source_path; + String extension; +}; + +struct File_Node{ + File_Node *next, *prev; +}; + +struct Editing_File{ + File_Node node; + Editing_File_Settings settings; + union{ + Editing_File_State state; + Editing_File_Preload preload; + }; + Editing_File_Name name; +}; + +struct File_Table_Entry{ + String name; + u32 hash; + i32 id; +}; + +struct File_Table{ + File_Table_Entry *table; + i32 count, max; +}; + +internal u32 +get_file_hash(String name){ + u32 x = 5381; + int i = 0; + char c; + while (i < name.size){ + c = name.str[i++]; + x = ((x << 5) + x) + c; + } + return x; +} + +internal b32 +table_add(File_Table *table, String name, i32 id){ + Assert(table->count * 3 < table->max * 2); + + File_Table_Entry entry, e; + i32 i; + + entry.name = name; + entry.id = id; + entry.hash = get_file_hash(name); + i = entry.hash % table->max; + while ((e = table->table[i]).name.str){ + if (e.hash == entry.hash && match(e.name, entry.name)){ + return 1; + } + i = (i + 1) % table->max; + } + table->table[i] = entry; + ++table->count; + + return 0; +} + +internal b32 +table_find_pos(File_Table *table, String name, i32 *index){ + File_Table_Entry e; + i32 i; + u32 hash; + + hash = get_file_hash(name); + i = hash % table->max; + while ((e = table->table[i]).name.size){ + if (e.name.str && e.hash == hash && match(e.name, name)){ + *index = i; + return 1; + } + i = (i + 1) % table->max; + } + + return 0; +} + +inline b32 +table_find(File_Table *table, String name, i32 *id){ + i32 pos; + b32 r = table_find_pos(table, name, &pos); + if (r) *id = table->table[pos].id; + return r; +} + +inline b32 +table_remove(File_Table *table, String name){ + i32 pos; + b32 r = table_find_pos(table, name, &pos); + if (r){ + table->table[pos].name.str = 0; + --table->count; + } + return r; +} + +struct Working_Set{ + Editing_File *files; + i32 file_count, file_max; + File_Node free_sentinel; + File_Node used_sentinel; + + File_Table table; + + String clipboards[64]; + i32 clipboard_size, clipboard_max_size; + i32 clipboard_current, clipboard_rolling; +}; + +// Hot Directory + +struct Hot_Directory{ + String string; + File_List file_list; + char slash; +}; + +internal void +hot_directory_clean_end(Hot_Directory *hot_directory){ + String *str = &hot_directory->string; + if (str->size != 0 && str->str[str->size-1] != hot_directory->slash){ + str->size = reverse_seek_slash(*str) + 1; + str->str[str->size] = 0; + } +} + +internal i32 +hot_directory_quick_partition(File_Info *infos, i32 start, i32 pivot){ + File_Info *p = infos + pivot; + File_Info *a = infos + start; + for (i32 i = start; i < pivot; ++i, ++a){ + i32 comp = 0; + comp = p->folder - a->folder; + if (comp == 0) comp = compare(a->filename, p->filename); + if (comp < 0){ + Swap(*a, infos[start]); + ++start; + } + } + Swap(*p, infos[start]); + return start; +} + +internal void +hot_directory_quick_sort(File_Info *infos, i32 start, i32 pivot){ + i32 mid = hot_directory_quick_partition(infos, start, pivot); + if (start < mid-1) hot_directory_quick_sort(infos, start, mid-1); + if (mid+1 < pivot) hot_directory_quick_sort(infos, mid+1, pivot); +} + +inline void +hot_directory_fixup(Hot_Directory *hot_directory, Working_Set *working_set){ + File_List *files = &hot_directory->file_list; + if (files->count >= 2) + hot_directory_quick_sort(files->infos, 0, files->count - 1); +} + +inline void +hot_directory_set(System_Functions *system, Hot_Directory *hot_directory, + String str, Working_Set *working_set){ + b32 success = copy_checked(&hot_directory->string, str); + terminate_with_null(&hot_directory->string); + if (success){ + if (str.size > 0){ + system->set_file_list(&hot_directory->file_list, str); + } + else{ + system->set_file_list(&hot_directory->file_list, make_string((char*)1, 0)); + } + } + hot_directory_fixup(hot_directory, working_set); +} + +inline void +hot_directory_reload(System_Functions *system, Hot_Directory *hot_directory, Working_Set *working_set){ + system->set_file_list(&hot_directory->file_list, hot_directory->string); + hot_directory_fixup(hot_directory, working_set); +} + +internal void +hot_directory_init(Hot_Directory *hot_directory, String base, String dir, char slash){ + hot_directory->string = base; + hot_directory->string.str[255] = 0; + hot_directory->string.size = 0; + copy(&hot_directory->string, dir); + append(&hot_directory->string, slash); + hot_directory->slash = slash; +} + +struct Hot_Directory_Match{ + String filename; + b32 is_folder; +}; + +internal b32 +filename_match(String query, Absolutes *absolutes, String filename, b32 case_sensitive){ + b32 result; + result = (query.size == 0); + replace_char(query, '\\', '/'); + replace_char(filename, '\\', '/'); + if (!result) result = wildcard_match(absolutes, filename, case_sensitive); + return result; +} + +internal Hot_Directory_Match +hot_directory_first_match(Hot_Directory *hot_directory, + String str, + b32 include_files, + b32 exact_match, + b32 case_sensitive){ + Hot_Directory_Match result = {}; + + replace_char(str, '\\', '/'); + + Absolutes absolutes; + if (!exact_match) + get_absolutes(str, &absolutes, 1, 1); + + File_List *files = &hot_directory->file_list; + File_Info *info, *end; + end = files->infos + files->count; + for (info = files->infos; info != end; ++info){ + String filename = info->filename; + b32 is_match = 0; + if (exact_match){ + if (case_sensitive){ + if (match(filename, str)) is_match = 1; + } + else{ + if (match_unsensitive(filename, str)) is_match = 1; + } + } + else{ + if (filename_match(str, &absolutes, filename, case_sensitive)) is_match = 1; + } + + if (is_match){ + result.is_folder = info->folder; + result.filename = filename; + break; + } + } + + return result; +} + +enum File_Sync_State{ + SYNC_GOOD, + SYNC_BEHIND_OS, + SYNC_UNSAVED +}; + +inline File_Sync_State +buffer_get_sync(Editing_File *file){ + File_Sync_State result = SYNC_GOOD; + if (file->state.last_4ed_write_time != file->state.last_sys_write_time) + result = SYNC_BEHIND_OS; + else if (file->state.last_4ed_edit_time > file->state.last_sys_write_time) + result = SYNC_UNSAVED; + return result; +} + +inline b32 +buffer_needs_save(Editing_File *file){ + b32 result = 0; + if (file->settings.unimportant == 0) + if (buffer_get_sync(file) == SYNC_UNSAVED) + result = 1; + return(result); +} + +inline b32 +file_is_ready(Editing_File *file){ + b32 result = 0; + if (file && file->state.is_loading == 0){ + result = 1; + } + return(result); +} + +inline Editing_File* +working_set_contains(Working_Set *working, String filename){ + Editing_File *result = 0; + i32 id; + replace_char(filename, '\\', '/'); + if (table_find(&working->table, filename, &id)){ + if (id >= 0 && id <= working->file_max){ + result = working->files + id; + } + } + return (result); +} + +// TODO(allen): Pick better first options. +internal Editing_File* +working_set_lookup_file(Working_Set *working_set, String string){ + Editing_File *file = 0; + + replace_char(string, '\\', '/'); + + { + File_Node *node, *used_nodes; + used_nodes = &working_set->used_sentinel; + for (dll_items(node, used_nodes)){ + file = (Editing_File*)node; + if (string.size == 0 || match(string, file->name.live_name)){ + break; + } + } + if (node == used_nodes) file = 0; + } + + if (!file){ + File_Node *node, *used_nodes; + used_nodes = &working_set->used_sentinel; + for (dll_items(node, used_nodes)){ + file = (Editing_File*)node; + if (string.size == 0 || has_substr(file->name.live_name, string)){ + break; + } + } + if (node == used_nodes) file = 0; + } + + return (file); +} + +struct Get_File_Result{ + Editing_File *file; + i32 index; +}; + +internal Get_File_Result +working_set_get_available_file(Working_Set *working_set){ + Get_File_Result result = {}; + File_Node *node; + + if (working_set->file_count < working_set->file_max){ + node = working_set->free_sentinel.next; + Assert(node != &working_set->free_sentinel); + + result.file = (Editing_File*)node; + result.index = (i32)(result.file - working_set->files); + + ++working_set->file_count; + + dll_remove(node); + *result.file = {}; + dll_insert(&working_set->used_sentinel, node); + } + + return result; +} + +inline void +working_set_free_file(Working_Set *working_set, Editing_File *file){ + file->state.is_dummy = 1; + dll_remove(&file->node); + dll_insert(&working_set->free_sentinel, &file->node); + --working_set->file_count; +} + +inline Get_File_Result +working_set_get_file(Working_Set *working_set, i32 id, b32 require_active){ + Get_File_Result result = {}; + if (id > 0 && id <= working_set->file_max){ + result.file = working_set->files + id; + result.index = id; + if (result.file->state.is_dummy && require_active){ + result.file = 0; + result.index = 0; + } + } + return(result); +} + +inline void +file_set_to_loading(Editing_File *file){ + file->state = {}; + file->settings = {}; + file->state.is_loading = 1; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_file_view.cpp b/test_data/lots_of_files/4ed_file_view.cpp new file mode 100644 index 0000000..cb1ba82 --- /dev/null +++ b/test_data/lots_of_files/4ed_file_view.cpp @@ -0,0 +1,4164 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 19.08.2015 + * + * File editing view for 4coder + * + */ + +// TOP + +enum Interactive_Action{ + IAct_Open, + IAct_Save_As, + IAct_New, + IAct_Switch, + IAct_Kill, + IAct_Sure_To_Kill +}; + +enum Interactive_Interaction{ + IInt_Sys_File_List, + IInt_Live_File_List, + IInt_Sure_To_Kill +}; + +struct View_Mode{ + i32 rewrite; +}; + +enum View_Widget_Type{ + FWIDG_NONE, + FWIDG_TIMELINES, + // never below this + FWIDG_TYPE_COUNT +}; + +struct View_Widget{ + UI_State state; + View_Widget_Type type; + i32 height_; + struct{ + b32 undo_line; + b32 history_line; + } timeline; +}; + +enum View_UI{ + VUI_None, + VUI_Theme, + VUI_Interactive, + VUI_Menu, + VUI_Config, +}; + +enum Color_View_Mode{ + CV_Mode_Library, + CV_Mode_Import_File, + CV_Mode_Export_File, + CV_Mode_Import, + CV_Mode_Export, + CV_Mode_Import_Wait, + CV_Mode_Adjusting +}; + +struct View{ + View *next, *prev; + b32 in_use; + i32 id; + + Models *models; + + Panel *panel; + Command_Map *map; + + Editing_File *file; + + UI_State ui_state; + View_UI showing_ui; + + // interactive stuff + Interactive_Interaction interaction; + Interactive_Action action; + b32 finished; + char query_[256]; + char dest_[256]; + String query; + String dest; + i32 user_action; + + // theme stuff + View *hot_file_view; + u32 *palette; + i32 palette_size; + Color_View_Mode color_mode; + Super_Color color; + Color_Highlight highlight; + b32 p4c_only; + Style_Library inspecting_styles; + b8 import_export_check[64]; + i32 import_file_id; + + // file stuff + i32 font_advance; + i32 font_height; + + Full_Cursor cursor; + i32 mark; + f32 scroll_y, target_y, prev_target_y; + f32 scroll_x, target_x, prev_target_x; + f32 preferred_x; + i32 scroll_i; + f32 scroll_min_limit; + + Full_Cursor temp_highlight; + i32 temp_highlight_end_pos; + b32 show_temp_highlight; + + View_Mode mode, next_mode; + View_Widget widget; + Query_Set query_set; + i32 scrub_max; + + b32 unwrapped_lines; + b32 show_whitespace; + b32 file_locked; + + i32 line_count, line_max; + f32 *line_wrap_y; + + Command_Map *map_for_file; + b32 reinit_scrolling; +}; + +struct View_And_ID{ + View *view; + i32 id; +}; + +#define LockLevel_Open 0 +#define LockLevel_NoWrite 1 +#define LockLevel_NoUpdate 2 + +inline i32 +view_lock_level(View *view){ + i32 result = LockLevel_Open; + if (view->showing_ui != VUI_None) result = LockLevel_NoUpdate; + else if (view->file_locked || + (view->file && view->file->settings.read_only)) result = LockLevel_NoWrite; + return(result); +} + +inline f32 +view_compute_width(View *view){ + Panel *panel = view->panel; + return (f32)(panel->inner.x1 - panel->inner.x0); +} + +inline f32 +view_compute_height(View *view){ + Panel *panel = view->panel; + return (f32)(panel->inner.y1 - panel->inner.y0); +} + +struct View_Iter{ + View *view; + + Editing_File *file; + View *skip; + Panel *used_panels; + Panel *panel; +}; + +internal View_Iter +file_view_iter_next(View_Iter iter){ + View *file_view; + + for (iter.panel = iter.panel->next; iter.panel != iter.used_panels; iter.panel = iter.panel->next){ + file_view = iter.panel->view; + if (file_view != iter.skip && (file_view->file == iter.file || iter.file == 0)){ + iter.view = file_view; + break; + } + } + + return(iter); +} + +internal View_Iter +file_view_iter_init(Editing_Layout *layout, Editing_File *file, View *skip){ + View_Iter result; + result.used_panels = &layout->used_sentinel; + result.panel = result.used_panels; + result.file = file; + result.skip = skip; + + result = file_view_iter_next(result); + + return(result); +} + +internal b32 +file_view_iter_good(View_Iter iter){ + b32 result = (iter.panel != iter.used_panels); + return(result); +} + +inline b32 +starts_new_line(u8 character){ + return (character == '\n'); +} + +inline void +file_init_strings(Editing_File *file){ + file->name.source_path = make_fixed_width_string(file->name.source_path_); + file->name.live_name = make_fixed_width_string(file->name.live_name_); + file->name.extension = make_fixed_width_string(file->name.extension_); +} + +inline void +file_set_name(Working_Set *working_set, Editing_File *file, char *filename){ + String f, ext; + + Assert(file->name.live_name.str != 0); + + f = make_string_slowly(filename); + copy_checked(&file->name.source_path, f); + + file->name.live_name.size = 0; + get_front_of_directory(&file->name.live_name, f); + + if (file->name.source_path.size == file->name.live_name.size){ + file->name.extension.size = 0; + } + else{ + ext = file_extension(f); + copy(&file->name.extension, ext); + } + + { + File_Node *node, *used_nodes; + Editing_File *file_ptr; + i32 file_x, original_len; + b32 hit_conflict; + + used_nodes = &working_set->used_sentinel; + original_len = file->name.live_name.size; + hit_conflict = 1; + file_x = 0; + while (hit_conflict){ + hit_conflict = 0; + for (dll_items(node, used_nodes)){ + file_ptr = (Editing_File*)node; + if (file_ptr != file && file_is_ready(file_ptr)){ + if (match(file->name.live_name, file_ptr->name.live_name)){ + ++file_x; + hit_conflict = 1; + break; + } + } + } + + if (hit_conflict){ + file->name.live_name.size = original_len; + append(&file->name.live_name, " <"); + append_int_to_str(file_x, &file->name.live_name); + append(&file->name.live_name, ">"); + } + } + } +} + +inline void +file_synchronize_times(System_Functions *system, Editing_File *file, char *filename){ + u64 stamp = system->file_time_stamp(filename); + if (stamp > 0){ + file->state.last_4ed_write_time = stamp; + file->state.last_4ed_edit_time = stamp; + file->state.last_sys_write_time = stamp; + } +} + +internal i32 +file_save(System_Functions *system, Exchange *exchange, Mem_Options *mem, + Editing_File *file, char *filename){ + i32 result = 0; + + i32 max, size; + b32 dos_write_mode = file->settings.dos_write_mode; + char *data; + Buffer_Type *buffer = &file->state.buffer; + + if (dos_write_mode) + max = buffer_size(buffer) + buffer->line_count + 1; + else + max = buffer_size(buffer); + + data = (char*)general_memory_allocate(&mem->general, max, 0); + Assert(data); + + if (dos_write_mode) + size = buffer_convert_out(buffer, data, max); + else + buffer_stringify(buffer, 0, size = max, data); + + result = exchange_save_file(exchange, filename, str_size(filename), (byte*)data, size, max); + + if (result == 0){ + general_memory_free(&mem->general, data); + } + + file_synchronize_times(system, file, filename); + + return(result); +} + +inline b32 +file_save_and_set_names(System_Functions *system, Exchange *exchange, + Mem_Options *mem, Working_Set *working_set, Editing_File *file, + char *filename){ + b32 result = 0; + result = file_save(system, exchange, mem, file, filename); + if (result){ + file_set_name(working_set, file, filename); + } + return result; +} + +enum File_Bubble_Type{ + BUBBLE_BUFFER = 1, + BUBBLE_STARTS, + BUBBLE_WIDTHS, + BUBBLE_WRAPS, + BUBBLE_TOKENS, + BUBBLE_UNDO_STRING, + BUBBLE_UNDO, + BUBBLE_UNDO_CHILDREN, + // + FILE_BUBBLE_TYPE_END, +}; + +#define GROW_FAILED 0 +#define GROW_NOT_NEEDED 1 +#define GROW_SUCCESS 2 + +internal i32 +file_grow_starts_widths_as_needed(General_Memory *general, Buffer_Type *buffer, i32 additional_lines){ + b32 result = GROW_NOT_NEEDED; + i32 max = buffer->line_max; + i32 count = buffer->line_count; + i32 target_lines = count + additional_lines; + Assert(max == buffer->widths_max); + + if (target_lines > max || max == 0){ + max = LargeRoundUp(target_lines + max, Kbytes(1)); + + f32 *new_widths = (f32*)general_memory_reallocate( + general, buffer->line_widths, + sizeof(f32)*count, sizeof(f32)*max, BUBBLE_WIDTHS); + + i32 *new_lines = (i32*)general_memory_reallocate( + general, buffer->line_starts, + sizeof(i32)*count, sizeof(i32)*max, BUBBLE_STARTS); + + if (new_lines){ + buffer->line_starts = new_lines; + buffer->line_max = max; + } + if (new_widths){ + buffer->line_widths = new_widths; + buffer->widths_max = max; + } + if (new_lines && new_widths){ + result = GROW_SUCCESS; + } + else{ + result = GROW_FAILED; + } + } + + return(result); +} + +internal void +file_measure_starts_widths(System_Functions *system, General_Memory *general, + Buffer_Type *buffer, float *advance_data){ + ProfileMomentFunction(); + if (!buffer->line_starts){ + i32 max = buffer->line_max = Kbytes(1); + buffer->line_starts = (i32*)general_memory_allocate(general, max*sizeof(i32), BUBBLE_STARTS); + TentativeAssert(buffer->line_starts); + // TODO(allen): when unable to allocate? + } + if (!buffer->line_widths){ + i32 max = buffer->widths_max = Kbytes(1); + buffer->line_widths = (f32*)general_memory_allocate(general, max*sizeof(f32), BUBBLE_STARTS); + TentativeAssert(buffer->line_starts); + // TODO(allen): when unable to allocate? + } + + Buffer_Measure_Starts state = {}; + while (buffer_measure_starts_widths(&state, buffer, advance_data)){ + i32 count = state.count; + i32 max = buffer->line_max; + max = ((max + 1) << 1); + + { + i32 *new_lines = (i32*)general_memory_reallocate( + general, buffer->line_starts, sizeof(i32)*count, sizeof(i32)*max, BUBBLE_STARTS); + + // TODO(allen): when unable to grow? + TentativeAssert(new_lines); + buffer->line_starts = new_lines; + buffer->line_max = max; + } + + { + f32 *new_lines = (f32*) + general_memory_reallocate(general, buffer->line_widths, + sizeof(f32)*count, sizeof(f32)*max, BUBBLE_WIDTHS); + + // TODO(allen): when unable to grow? + TentativeAssert(new_lines); + buffer->line_widths = new_lines; + buffer->widths_max = max; + } + + } + buffer->line_count = state.count; + buffer->widths_count = state.count; +} + +struct Opaque_Font_Advance{ + void *data; + int stride; +}; + +inline Opaque_Font_Advance +get_opaque_font_advance(Render_Font *font){ + Opaque_Font_Advance result; + result.data = (char*)font->chardata + OffsetOfPtr(font->chardata, xadvance); + result.stride = sizeof(*font->chardata); + return result; +} + +internal void +file_remeasure_widths_(System_Functions *system, + General_Memory *general, Buffer_Type *buffer, Render_Font *font, + i32 line_start, i32 line_end, i32 line_shift){ + ProfileMomentFunction(); + file_grow_starts_widths_as_needed(general, buffer, line_shift); + buffer_remeasure_widths(buffer, font->advance_data, line_start, line_end, line_shift); +} + +inline i32 +view_wrapped_line_span(f32 line_width, f32 max_width){ + i32 line_count = CEIL32(line_width / max_width); + if (line_count == 0) line_count = 1; + return line_count; +} + +internal i32 +view_compute_lowest_line(View *view){ + i32 lowest_line = 0; + i32 last_line = view->line_count - 1; + if (last_line > 0){ + if (view->unwrapped_lines){ + lowest_line = last_line; + } + else{ + f32 wrap_y = view->line_wrap_y[last_line]; + lowest_line = FLOOR32(wrap_y / view->font_height); + f32 max_width = view_compute_width(view); + + Editing_File *file = view->file; + Assert(!file->state.is_dummy); + f32 width = file->state.buffer.line_widths[last_line]; + i32 line_span = view_wrapped_line_span(width, max_width); + lowest_line += line_span - 1; + } + } + return lowest_line; +} + +internal void +view_measure_wraps(System_Functions *system, + General_Memory *general, View *view){ + ProfileMomentFunction(); + Buffer_Type *buffer; + + buffer = &view->file->state.buffer; + i32 line_count = buffer->line_count; + + if (view->line_max < line_count){ + i32 max = view->line_max = LargeRoundUp(line_count, Kbytes(1)); + if (view->line_wrap_y){ + view->line_wrap_y = (real32*) + general_memory_reallocate_nocopy(general, view->line_wrap_y, sizeof(real32)*max, BUBBLE_WRAPS); + } + else{ + view->line_wrap_y = (real32*) + general_memory_allocate(general, sizeof(real32)*max, BUBBLE_WRAPS); + } + } + + f32 line_height = (f32)view->font_height; + f32 max_width = view_compute_width(view); + buffer_measure_wrap_y(buffer, view->line_wrap_y, line_height, max_width); + + view->line_count = line_count; +} + +internal void* +alloc_for_buffer(void *context, int *size){ + *size = LargeRoundUp(*size, Kbytes(4)); + void *data = general_memory_allocate((General_Memory*)context, *size, BUBBLE_BUFFER); + return data; +} + +internal void +file_create_from_string(System_Functions *system, Models *models, + Editing_File *file, char *filename, String val, b8 read_only = 0){ + + Font_Set *font_set = models->font_set; + Working_Set *working_set = &models->working_set; + General_Memory *general = &models->mem.general; + Partition *part = &models->mem.part; + Buffer_Init_Type init; + i32 page_size, scratch_size, init_success; + + file->state = {}; + + init = buffer_begin_init(&file->state.buffer, val.str, val.size); + for (; buffer_init_need_more(&init); ){ + page_size = buffer_init_page_size(&init); + page_size = LargeRoundUp(page_size, Kbytes(4)); + if (page_size < Kbytes(4)) page_size = Kbytes(4); + void *data = general_memory_allocate(general, page_size, BUBBLE_BUFFER); + buffer_init_provide_page(&init, data, page_size); + } + + scratch_size = partition_remaining(part); + Assert(scratch_size > 0); + init_success = buffer_end_init(&init, part->base + part->pos, scratch_size); + AllowLocal(init_success); + Assert(init_success); + + if (buffer_size(&file->state.buffer) < val.size){ + file->settings.dos_write_mode = 1; + } + + file_init_strings(file); + file_set_name(working_set, file, (char*)filename); + + file->state.font_id = models->global_font.font_id; + + file_synchronize_times(system, file, filename); + + Render_Font *font = get_font_info(font_set, file->state.font_id)->font; + float *advance_data = 0; + if (font) advance_data = font->advance_data; + file_measure_starts_widths(system, general, &file->state.buffer, advance_data); + + file->settings.read_only = read_only; + if (!read_only){ + i32 request_size = Kbytes(64); + file->state.undo.undo.max = request_size; + file->state.undo.undo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); + file->state.undo.undo.edit_max = request_size / sizeof(Edit_Step); + file->state.undo.undo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); + + file->state.undo.redo.max = request_size; + file->state.undo.redo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); + file->state.undo.redo.edit_max = request_size / sizeof(Edit_Step); + file->state.undo.redo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); + + file->state.undo.history.max = request_size; + file->state.undo.history.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); + file->state.undo.history.edit_max = request_size / sizeof(Edit_Step); + file->state.undo.history.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); + + file->state.undo.children.max = request_size; + file->state.undo.children.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); + file->state.undo.children.edit_max = request_size / sizeof(Buffer_Edit); + file->state.undo.children.edits = (Buffer_Edit*)general_memory_allocate(general, request_size, BUBBLE_UNDO); + + file->state.undo.history_block_count = 1; + file->state.undo.history_head_block = 0; + file->state.undo.current_block_normal = 1; + } +} + +internal b32 +file_create_empty(System_Functions *system, + Models *models, Editing_File *file, char *filename){ + + file_create_from_string(system, models, file, filename, {}); + return (1); +} + +internal b32 +file_create_read_only(System_Functions *system, + Models *models, Editing_File *file, char *filename){ + + file_create_from_string(system, models, file, filename, {}, 1); + return (1); +} + +internal void +file_close(System_Functions *system, General_Memory *general, Editing_File *file){ + if (file->state.still_lexing){ + system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); + if (file->state.swap_stack.tokens){ + general_memory_free(general, file->state.swap_stack.tokens); + file->state.swap_stack.tokens = 0; + } + } + if (file->state.token_stack.tokens){ + general_memory_free(general, file->state.token_stack.tokens); + } + + Buffer_Type *buffer = &file->state.buffer; + if (buffer->data){ + general_memory_free(general, buffer->data); + general_memory_free(general, buffer->line_starts); + general_memory_free(general, buffer->line_widths); + } + + if (file->state.undo.undo.edits){ + general_memory_free(general, file->state.undo.undo.strings); + general_memory_free(general, file->state.undo.undo.edits); + + general_memory_free(general, file->state.undo.redo.strings); + general_memory_free(general, file->state.undo.redo.edits); + + general_memory_free(general, file->state.undo.history.strings); + general_memory_free(general, file->state.undo.history.edits); + + general_memory_free(general, file->state.undo.children.strings); + general_memory_free(general, file->state.undo.children.edits); + } +} + +struct Shift_Information{ + i32 start, end, amount; +}; + +internal +Job_Callback_Sig(job_full_lex){ + Editing_File *file = (Editing_File*)data[0]; + General_Memory *general = (General_Memory*)data[1]; + + Cpp_File cpp_file; + cpp_file.data = file->state.buffer.data; + cpp_file.size = file->state.buffer.size; + + Cpp_Token_Stack tokens; + tokens.tokens = (Cpp_Token*)memory->data; + tokens.max_count = memory->size / sizeof(Cpp_Token); + tokens.count = 0; + + Cpp_Lex_Data status; + status = cpp_lex_file_nonalloc(cpp_file, &tokens); + + while (!status.complete){ + system->grow_thread_memory(memory); + tokens.tokens = (Cpp_Token*)memory->data; + tokens.max_count = memory->size / sizeof(Cpp_Token); + status = cpp_lex_file_nonalloc(cpp_file, &tokens, status); + } + + i32 new_max = LargeRoundUp(tokens.count+1, Kbytes(1)); + + system->acquire_lock(FRAME_LOCK); + { + Assert(file->state.swap_stack.tokens == 0); + file->state.swap_stack.tokens = (Cpp_Token*) + general_memory_allocate(general, new_max*sizeof(Cpp_Token), BUBBLE_TOKENS); + } + system->release_lock(FRAME_LOCK); + + u8 *dest = (u8*)file->state.swap_stack.tokens; + u8 *src = (u8*)tokens.tokens; + + memcpy(dest, src, tokens.count*sizeof(Cpp_Token)); + + system->acquire_lock(FRAME_LOCK); + { + file->state.token_stack.count = tokens.count; + file->state.token_stack.max_count = new_max; + if (file->state.token_stack.tokens) + general_memory_free(general, file->state.token_stack.tokens); + file->state.token_stack.tokens = file->state.swap_stack.tokens; + file->state.swap_stack.tokens = 0; + } + system->release_lock(FRAME_LOCK); + + exchange->force_redraw = 1; + + // NOTE(allen): These are outside the locked section because I don't + // think getting these out of order will cause critical bugs, and I + // want to minimize what's done in locked sections. + file->state.tokens_complete = 1; + file->state.still_lexing = 0; +} + + +internal void +file_kill_tokens(System_Functions *system, + General_Memory *general, Editing_File *file){ + file->settings.tokens_exist = 0; + if (file->state.still_lexing){ + system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); + if (file->state.swap_stack.tokens){ + general_memory_free(general, file->state.swap_stack.tokens); + file->state.swap_stack.tokens = 0; + } + } + if (file->state.token_stack.tokens){ + general_memory_free(general, file->state.token_stack.tokens); + } + file->state.tokens_complete = 0; + file->state.token_stack = {}; +} + +#if BUFFER_EXPERIMENT_SCALPEL <= 0 +internal void +file_first_lex_parallel(System_Functions *system, + General_Memory *general, Editing_File *file){ + file->settings.tokens_exist = 1; + + if (file->state.is_loading == 0 && file->state.still_lexing == 0){ + Assert(file->state.token_stack.tokens == 0); + + file->state.tokens_complete = 0; + file->state.still_lexing = 1; + + Job_Data job; + job.callback = job_full_lex; + job.data[0] = file; + job.data[1] = general; + job.memory_request = Kbytes(64); + file->state.lex_job = system->post_job(BACKGROUND_THREADS, job); +#endif + } +} + +internal void +file_relex_parallel(System_Functions *system, + Mem_Options *mem, Editing_File *file, + i32 start_i, i32 end_i, i32 amount){ + General_Memory *general = &mem->general; + Partition *part = &mem->part; + if (file->state.token_stack.tokens == 0){ + file_first_lex_parallel(system, general, file); + return; + } + + b32 inline_lex = !file->state.still_lexing; + if (inline_lex){ + Cpp_File cpp_file; + cpp_file.data = file->state.buffer.data; + cpp_file.size = file->state.buffer.size; + + Cpp_Token_Stack *stack = &file->state.token_stack; + + Cpp_Relex_State state = + cpp_relex_nonalloc_start(cpp_file, stack, + start_i, end_i, amount, 100); + + Temp_Memory temp = begin_temp_memory(part); + i32 relex_end; + Cpp_Token_Stack relex_space; + relex_space.count = 0; + relex_space.max_count = state.space_request; + relex_space.tokens = push_array(part, Cpp_Token, relex_space.max_count); + if (cpp_relex_nonalloc_main(&state, &relex_space, &relex_end)){ + inline_lex = 0; + } + else{ + i32 delete_amount = relex_end - state.start_token_i; + i32 shift_amount = relex_space.count - delete_amount; + + if (shift_amount != 0){ + int new_count = stack->count + shift_amount; + if (new_count > stack->max_count){ + int new_max = LargeRoundUp(new_count, Kbytes(1)); + stack->tokens = (Cpp_Token*) + general_memory_reallocate(general, stack->tokens, + stack->count*sizeof(Cpp_Token), + new_max*sizeof(Cpp_Token), BUBBLE_TOKENS); + stack->max_count = new_max; + } + + int shift_size = stack->count - relex_end; + if (shift_size > 0){ + Cpp_Token *old_base = stack->tokens + relex_end; + memmove(old_base + shift_amount, old_base, + sizeof(Cpp_Token)*shift_size); + } + + stack->count += shift_amount; + } + + memcpy(state.stack->tokens + state.start_token_i, relex_space.tokens, + sizeof(Cpp_Token)*relex_space.count); + } + + end_temp_memory(temp); + } + + if (!inline_lex){ + i32 end_token_i = cpp_get_end_token(&file->state.token_stack, end_i); + cpp_shift_token_starts(&file->state.token_stack, end_token_i, amount); + --end_token_i; + if (end_token_i >= 0){ + Cpp_Token *token = file->state.token_stack.tokens + end_token_i; + if (token->start < end_i && token->start + token->size > end_i){ + token->size += amount; + } + } + + file->state.still_lexing = 1; + + Job_Data job; + job.callback = job_full_lex; + job.data[0] = file; + job.data[1] = general; + job.memory_request = Kbytes(64); + file->state.lex_job = system->post_job(BACKGROUND_THREADS, job); + } +} + +internal void +undo_stack_grow_string(General_Memory *general, Edit_Stack *stack, i32 extra_size){ + i32 old_max = stack->max; + u8 *old_str = stack->strings; + i32 new_max = old_max*2 + extra_size; + u8 *new_str = (u8*) + general_memory_reallocate(general, old_str, old_max, new_max); + stack->strings = new_str; + stack->max = new_max; +} + +internal void +undo_stack_grow_edits(General_Memory *general, Edit_Stack *stack){ + i32 old_max = stack->edit_max; + Edit_Step *old_eds = stack->edits; + i32 new_max = old_max*2 + 2; + Edit_Step *new_eds = (Edit_Step*) + general_memory_reallocate(general, old_eds, old_max*sizeof(Edit_Step), new_max*sizeof(Edit_Step)); + stack->edits = new_eds; + stack->edit_max = new_max; +} + +internal void +child_stack_grow_string(General_Memory *general, Small_Edit_Stack *stack, i32 extra_size){ + i32 old_max = stack->max; + u8 *old_str = stack->strings; + i32 new_max = old_max*2 + extra_size; + u8 *new_str = (u8*) + general_memory_reallocate(general, old_str, old_max, new_max); + stack->strings = new_str; + stack->max = new_max; +} + +internal void +child_stack_grow_edits(General_Memory *general, Small_Edit_Stack *stack, i32 amount){ + i32 old_max = stack->edit_max; + Buffer_Edit *old_eds = stack->edits; + i32 new_max = old_max*2 + amount; + Buffer_Edit *new_eds = (Buffer_Edit*) + general_memory_reallocate(general, old_eds, old_max*sizeof(Buffer_Edit), new_max*sizeof(Buffer_Edit)); + stack->edits = new_eds; + stack->edit_max = new_max; +} + +internal i32 +undo_children_push(General_Memory *general, Small_Edit_Stack *children, + Buffer_Edit *edits, i32 edit_count, u8 *strings, i32 string_size){ + i32 result = children->edit_count; + if (children->edit_count + edit_count > children->edit_max) + child_stack_grow_edits(general, children, edit_count); + + if (children->size + string_size > children->max) + child_stack_grow_string(general, children, string_size); + + memcpy(children->edits + children->edit_count, edits, edit_count*sizeof(Buffer_Edit)); + memcpy(children->strings + children->size, strings, string_size); + + Buffer_Edit *edit = children->edits + children->edit_count; + i32 start_pos = children->size; + for (i32 i = 0; i < edit_count; ++i, ++edit){ + edit->str_start += start_pos; + } + + children->edit_count += edit_count; + children->size += string_size; + + return result; +} + +struct Edit_Spec{ + u8 *str; + Edit_Step step; +}; + +internal Edit_Step* +file_post_undo(General_Memory *general, Editing_File *file, + Edit_Step step, bool32 do_merge, bool32 can_merge){ + if (step.type == ED_NORMAL){ + file->state.undo.redo.size = 0; + file->state.undo.redo.edit_count = 0; + } + + Edit_Stack *undo = &file->state.undo.undo; + Edit_Step *result = 0; + + if (step.child_count == 0){ + if (step.edit.end - step.edit.start + undo->size > undo->max) + undo_stack_grow_string(general, undo, step.edit.end - step.edit.start); + + Buffer_Edit inv; + buffer_invert_edit(&file->state.buffer, step.edit, &inv, + (char*)undo->strings, &undo->size, undo->max); + + Edit_Step inv_step = {}; + inv_step.edit = inv; + inv_step.pre_pos = step.pre_pos; + inv_step.post_pos = step.post_pos; + inv_step.can_merge = (b8)can_merge; + inv_step.type = ED_UNDO; + + bool32 did_merge = 0; + if (do_merge && undo->edit_count > 0){ + Edit_Step prev = undo->edits[undo->edit_count-1]; + if (prev.can_merge && inv_step.edit.len == 0 && prev.edit.len == 0){ + if (prev.edit.end == inv_step.edit.start){ + did_merge = 1; + inv_step.edit.start = prev.edit.start; + inv_step.pre_pos = prev.pre_pos; + } + } + } + + if (did_merge){ + result = undo->edits + (undo->edit_count-1); + *result = inv_step; + } + else{ + if (undo->edit_count == undo->edit_max) + undo_stack_grow_edits(general, undo); + result = undo->edits + (undo->edit_count++); + *result = inv_step; + } + } + else{ + Edit_Step inv_step = {}; + inv_step.type = ED_UNDO; + inv_step.first_child = step.inverse_first_child; + inv_step.inverse_first_child = step.first_child; + inv_step.special_type = step.special_type; + inv_step.child_count = step.inverse_child_count; + inv_step.inverse_child_count = step.child_count; + + if (undo->edit_count == undo->edit_max) + undo_stack_grow_edits(general, undo); + result = undo->edits + (undo->edit_count++); + *result = inv_step; + } + return result; +} + +inline void +undo_stack_pop(Edit_Stack *stack){ + if (stack->edit_count > 0){ + Edit_Step *edit = stack->edits + (--stack->edit_count); + stack->size -= edit->edit.len; + } +} + +internal void +file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){ + Edit_Stack *redo = &file->state.undo.redo; + + if (step.child_count == 0){ + if (step.edit.end - step.edit.start + redo->size > redo->max) + undo_stack_grow_string(general, redo, step.edit.end - step.edit.start); + + Buffer_Edit inv; + buffer_invert_edit(&file->state.buffer, step.edit, &inv, + (char*)redo->strings, &redo->size, redo->max); + + Edit_Step inv_step = {}; + inv_step.edit = inv; + inv_step.pre_pos = step.pre_pos; + inv_step.post_pos = step.post_pos; + inv_step.type = ED_REDO; + + if (redo->edit_count == redo->edit_max) + undo_stack_grow_edits(general, redo); + redo->edits[redo->edit_count++] = inv_step; + } + else{ + Edit_Step inv_step = {}; + inv_step.type = ED_REDO; + inv_step.first_child = step.inverse_first_child; + inv_step.inverse_first_child = step.first_child; + inv_step.special_type = step.special_type; + inv_step.child_count = step.inverse_child_count; + inv_step.inverse_child_count = step.child_count; + + if (redo->edit_count == redo->edit_max) + undo_stack_grow_edits(general, redo); + redo->edits[redo->edit_count++] = inv_step; + } +} + +inline void +file_post_history_block(Editing_File *file, i32 pos){ + Assert(file->state.undo.history_head_block < pos); + Assert(pos < file->state.undo.history.edit_count); + + Edit_Step *history = file->state.undo.history.edits; + Edit_Step *step = history + file->state.undo.history_head_block; + step->next_block = pos; + step = history + pos; + step->prev_block = file->state.undo.history_head_block; + file->state.undo.history_head_block = pos; + ++file->state.undo.history_block_count; +} + +inline void +file_unpost_history_block(Editing_File *file){ + Assert(file->state.undo.history_block_count > 1); + --file->state.undo.history_block_count; + Edit_Step *old_head = file->state.undo.history.edits + file->state.undo.history_head_block; + file->state.undo.history_head_block = old_head->prev_block; +} + +internal Edit_Step* +file_post_history(General_Memory *general, Editing_File *file, + Edit_Step step, b32 do_merge, b32 can_merge){ + Edit_Stack *history = &file->state.undo.history; + Edit_Step *result = 0; + + persist Edit_Type reverse_types[4]; + if (reverse_types[ED_UNDO] == 0){ + reverse_types[ED_NORMAL] = ED_REVERSE_NORMAL; + reverse_types[ED_REVERSE_NORMAL] = ED_NORMAL; + reverse_types[ED_UNDO] = ED_REDO; + reverse_types[ED_REDO] = ED_UNDO; + } + + if (step.child_count == 0){ + if (step.edit.end - step.edit.start + history->size > history->max) + undo_stack_grow_string(general, history, step.edit.end - step.edit.start); + + Buffer_Edit inv; + buffer_invert_edit(&file->state.buffer, step.edit, &inv, + (char*)history->strings, &history->size, history->max); + + Edit_Step inv_step = {}; + inv_step.edit = inv; + inv_step.pre_pos = step.pre_pos; + inv_step.post_pos = step.post_pos; + inv_step.can_merge = (b8)can_merge; + inv_step.type = reverse_types[step.type]; + + bool32 did_merge = 0; + if (do_merge && history->edit_count > 0){ + Edit_Step prev = history->edits[history->edit_count-1]; + if (prev.can_merge && inv_step.edit.len == 0 && prev.edit.len == 0){ + if (prev.edit.end == inv_step.edit.start){ + did_merge = 1; + inv_step.edit.start = prev.edit.start; + inv_step.pre_pos = prev.pre_pos; + } + } + } + + if (did_merge){ + result = history->edits + (history->edit_count-1); + } + else{ + if (history->edit_count == history->edit_max) + undo_stack_grow_edits(general, history); + result = history->edits + (history->edit_count++); + } + + *result = inv_step; + } + else{ + Edit_Step inv_step = {}; + inv_step.type = reverse_types[step.type]; + inv_step.first_child = step.inverse_first_child; + inv_step.inverse_first_child = step.first_child; + inv_step.special_type = step.special_type; + inv_step.inverse_child_count = step.child_count; + inv_step.child_count = step.inverse_child_count; + + if (history->edit_count == history->edit_max) + undo_stack_grow_edits(general, history); + result = history->edits + (history->edit_count++); + *result = inv_step; + } + + return result; +} + +inline Full_Cursor +view_compute_cursor_from_pos(View *view, i32 pos){ + Editing_File *file = view->file; + Models *models = view->models; + Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font; + + Full_Cursor result = {}; + if (font){ + f32 max_width = view_compute_width(view); + result = buffer_cursor_from_pos(&file->state.buffer, pos, view->line_wrap_y, + max_width, (f32)view->font_height, font->advance_data); + } + return result; +} + +inline Full_Cursor +view_compute_cursor_from_unwrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 round_down = 0){ + Editing_File *file = view->file; + Models *models = view->models; + Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font; + + Full_Cursor result = {}; + if (font){ + f32 max_width = view_compute_width(view); + result = buffer_cursor_from_unwrapped_xy(&file->state.buffer, seek_x, seek_y, + round_down, view->line_wrap_y, + max_width, (f32)view->font_height, font->advance_data); + } + + return result; +} + +internal Full_Cursor +view_compute_cursor_from_wrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 round_down = 0){ + Editing_File *file = view->file; + Models *models = view->models; + Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font; + + Full_Cursor result = {}; + if (font){ + f32 max_width = view_compute_width(view); + result = buffer_cursor_from_wrapped_xy(&file->state.buffer, seek_x, seek_y, + round_down, view->line_wrap_y, + max_width, (f32)view->font_height, font->advance_data); + } + + return (result); +} + +internal Full_Cursor +view_compute_cursor_from_line_pos(View *view, i32 line, i32 pos){ + Editing_File *file = view->file; + Models *models = view->models; + Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font; + + Full_Cursor result = {}; + if (font){ + f32 max_width = view_compute_width(view); + result = buffer_cursor_from_line_character(&file->state.buffer, line, pos, + view->line_wrap_y, max_width, (f32)view->font_height, font->advance_data); + } + + return (result); +} + +inline Full_Cursor +view_compute_cursor(View *view, Buffer_Seek seek){ + Full_Cursor result = {}; + + switch(seek.type){ + case buffer_seek_pos: + result = view_compute_cursor_from_pos(view, seek.pos); + break; + + case buffer_seek_wrapped_xy: + result = view_compute_cursor_from_wrapped_xy(view, seek.x, seek.y); + break; + + case buffer_seek_unwrapped_xy: + result = view_compute_cursor_from_unwrapped_xy(view, seek.x, seek.y); + break; + + case buffer_seek_line_char: + result = view_compute_cursor_from_line_pos(view, seek.line, seek.character); + break; + } + + return (result); +} + +inline Full_Cursor +view_compute_cursor_from_xy(View *view, f32 seek_x, f32 seek_y){ + Full_Cursor result; + if (view->unwrapped_lines) result = view_compute_cursor_from_unwrapped_xy(view, seek_x, seek_y); + else result = view_compute_cursor_from_wrapped_xy(view, seek_x, seek_y); + return result; +} + +inline void +view_set_temp_highlight(View *view, i32 pos, i32 end_pos){ + view->temp_highlight = view_compute_cursor_from_pos(view, pos); + view->temp_highlight_end_pos = end_pos; + view->show_temp_highlight = 1; +} + +inline i32 +view_get_cursor_pos(View *view){ + i32 result; + if (view->show_temp_highlight){ + result = view->temp_highlight.pos; + } + else{ + result = view->cursor.pos; + } + return result; +} + +inline f32 +view_get_cursor_x(View *view){ + f32 result; + Full_Cursor *cursor; + if (view->show_temp_highlight){ + cursor = &view->temp_highlight; + } + else{ + cursor = &view->cursor; + } + if (view->unwrapped_lines){ + result = cursor->unwrapped_x; + } + else{ + result = cursor->wrapped_x; + } + return result; +} + +inline f32 +view_get_cursor_y(View *view){ + Full_Cursor *cursor; + f32 result; + + if (view->show_temp_highlight) cursor = &view->temp_highlight; + else cursor = &view->cursor; + + if (view->unwrapped_lines) result = cursor->unwrapped_y; + else result = cursor->wrapped_y; + + return result; +} + +internal void +view_set_file( + // NOTE(allen): These parameters are always meaningful + View *view, Editing_File *file, Models *models, + + // NOTE(allen): Necessary when file != 0 + System_Functions *system, Hook_Function *open_hook, Application_Links *app, + + // other + b32 set_vui = 1){ + + Font_Info *fnt_info; + + // TODO(allen): This belongs somewhere else. + fnt_info = get_font_info(models->font_set, models->global_font.font_id); + view->font_advance = fnt_info->advance; + view->font_height = fnt_info->height; + + // NOTE(allen): Stuff that doesn't assume file exists. + view->file = file; + view->cursor = {}; + + // NOTE(allen): Stuff that does assume file exists. + if (file){ + //view->locked = file->settings.super_locked; + view->unwrapped_lines = file->settings.unwrapped_lines; + + if (file_is_ready(file)){ + view_measure_wraps(system, &models->mem.general, view); + view->cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos); + + view->reinit_scrolling = 1; + } + } + + // TODO(allen): Bypass all this nonsense, it's a hack! Hooks need parameters! + // Just accept it and pass the file to the open hook when it is loaded. + if (file){ + if (open_hook && file->settings.is_initialized == 0){ + models->buffer_param_indices[models->buffer_param_count++] = (i32)(file - models->working_set.files); + open_hook(app); + models->buffer_param_count = 0; + file->settings.is_initialized = 1; + } + } + + if (set_vui){ + // TODO(allen): Fix this! There should be a way to easily separate setting a file, + // and switching to file mode, so that they don't cross over eachother like this. + view->ui_state = {}; + view->showing_ui = VUI_None; + } +} + +struct Relative_Scrolling{ + f32 scroll_x, scroll_y; + f32 target_x, target_y; + f32 scroll_min_limit; +}; + +internal Relative_Scrolling +view_get_relative_scrolling(View *view){ + Relative_Scrolling result; + f32 cursor_y; + cursor_y = view_get_cursor_y(view); + result.scroll_y = cursor_y - view->scroll_y; + result.target_y = cursor_y - view->target_y; + result.scroll_min_limit = view->scroll_min_limit; + return result; +} + +internal void +view_set_relative_scrolling(View *view, Relative_Scrolling scrolling){ + f32 cursor_y; + cursor_y = view_get_cursor_y(view); + view->scroll_y = cursor_y - scrolling.scroll_y; + view->target_y = cursor_y - scrolling.target_y; + if (view->target_y < scrolling.scroll_min_limit) view->target_y = scrolling.scroll_min_limit; +} + +inline void +view_cursor_move(View *view, Full_Cursor cursor){ + view->cursor = cursor; + view->preferred_x = view_get_cursor_x(view); + view->file->state.cursor_pos = view->cursor.pos; + view->show_temp_highlight = 0; +} + +inline void +view_cursor_move(View *view, i32 pos){ + Full_Cursor cursor = view_compute_cursor_from_pos(view, pos); + view_cursor_move(view, cursor); +} + +inline void +view_cursor_move(View *view, f32 x, f32 y, b32 round_down = 0){ + Full_Cursor cursor; + if (view->unwrapped_lines){ + cursor = view_compute_cursor_from_unwrapped_xy(view, x, y, round_down); + } + else{ + cursor = view_compute_cursor_from_wrapped_xy(view, x, y, round_down); + } + view_cursor_move(view, cursor); +} + +inline void +view_cursor_move(View *view, i32 line, i32 pos){ + Full_Cursor cursor = view_compute_cursor_from_line_pos(view, line, pos); + view_cursor_move(view, cursor); +} + +inline void +view_set_widget(View *view, View_Widget_Type type){ + view->widget.type = type; +} + + +inline i32_Rect +view_widget_rect(View *view, i32 font_height){ + Panel *panel = view->panel; + i32_Rect result = panel->inner; + + if (view->file){ + result.y0 = result.y0 + font_height + 2; + } + + return(result); +} + +enum History_Mode{ + hist_normal, + hist_backward, + hist_forward +}; + +internal void +file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step step, u8 *str, + History_Mode history_mode){ + if (!file->state.undo.undo.edits) return; + General_Memory *general = &mem->general; + + b32 can_merge = 0, do_merge = 0; + switch (step.type){ + case ED_NORMAL: + { + if (step.edit.len == 1 && str && char_is_alpha_numeric(*str)) can_merge = 1; + if (step.edit.len == 1 && str && (can_merge || char_is_whitespace(*str))) do_merge = 1; + + if (history_mode != hist_forward) + file_post_history(general, file, step, do_merge, can_merge); + + file_post_undo(general, file, step, do_merge, can_merge); + }break; + + case ED_REVERSE_NORMAL: + { + if (history_mode != hist_forward) + file_post_history(general, file, step, do_merge, can_merge); + + undo_stack_pop(&file->state.undo.undo); + + b32 restore_redos = 0; + Edit_Step *redo_end = 0; + + if (history_mode == hist_backward && file->state.undo.edit_history_cursor > 0){ + restore_redos = 1; + redo_end = file->state.undo.history.edits + (file->state.undo.edit_history_cursor - 1); + } + else if (history_mode == hist_forward && file->state.undo.history.edit_count > 0){ + restore_redos = 1; + redo_end = file->state.undo.history.edits + (file->state.undo.history.edit_count - 1); + } + + if (restore_redos){ + Edit_Step *redo_start = redo_end; + i32 steps_of_redo = 0; + i32 strings_of_redo = 0; + i32 undo_count = 0; + while (redo_start->type == ED_REDO || redo_start->type == ED_UNDO){ + if (redo_start->type == ED_REDO){ + if (undo_count > 0) --undo_count; + else{ + ++steps_of_redo; + strings_of_redo += redo_start->edit.len; + } + } + else{ + ++undo_count; + } + --redo_start; + } + + if (redo_start < redo_end){ + ++redo_start; + ++redo_end; + + if (file->state.undo.redo.edit_count + steps_of_redo > file->state.undo.redo.edit_max) + undo_stack_grow_edits(general, &file->state.undo.redo); + + if (file->state.undo.redo.size + strings_of_redo > file->state.undo.redo.max) + undo_stack_grow_string(general, &file->state.undo.redo, strings_of_redo); + + u8 *str_src = file->state.undo.history.strings + redo_end->edit.str_start; + u8 *str_dest_base = file->state.undo.redo.strings; + i32 str_redo_pos = file->state.undo.redo.size + strings_of_redo; + + Edit_Step *edit_src = redo_end; + Edit_Step *edit_dest = + file->state.undo.redo.edits + file->state.undo.redo.edit_count + steps_of_redo; + + i32 undo_count = 0; + for (i32 i = 0; i < steps_of_redo;){ + --edit_src; + str_src -= edit_src->edit.len; + if (edit_src->type == ED_REDO){ + if (undo_count > 0){ + --undo_count; + } + else{ + ++i; + + --edit_dest; + *edit_dest = *edit_src; + + str_redo_pos -= edit_dest->edit.len; + edit_dest->edit.str_start = str_redo_pos; + + memcpy(str_dest_base + str_redo_pos, str_src, edit_dest->edit.len); + } + } + else{ + ++undo_count; + } + } + Assert(undo_count == 0); + + file->state.undo.redo.size += strings_of_redo; + file->state.undo.redo.edit_count += steps_of_redo; + } + } + }break; + + case ED_UNDO: + { + if (history_mode != hist_forward) + file_post_history(general, file, step, do_merge, can_merge); + file_post_redo(general, file, step); + undo_stack_pop(&file->state.undo.undo); + }break; + + case ED_REDO: + { + if (step.edit.len == 1 && str && char_is_alpha_numeric(*str)) can_merge = 1; + if (step.edit.len == 1 && str && (can_merge || char_is_whitespace(*str))) do_merge = 1; + + if (history_mode != hist_forward) + file_post_history(general, file, step, do_merge, can_merge); + + file_post_undo(general, file, step, do_merge, can_merge); + undo_stack_pop(&file->state.undo.redo); + }break; + } + + if (history_mode != hist_forward){ + if (step.type == ED_UNDO || step.type == ED_REDO){ + if (file->state.undo.current_block_normal){ + file_post_history_block(file, file->state.undo.history.edit_count - 1); + file->state.undo.current_block_normal = 0; + } + } + else{ + if (!file->state.undo.current_block_normal){ + file_post_history_block(file, file->state.undo.history.edit_count - 1); + file->state.undo.current_block_normal = 1; + } + } + } + else{ + if (file->state.undo.history_head_block == file->state.undo.history.edit_count){ + file_unpost_history_block(file); + file->state.undo.current_block_normal = !file->state.undo.current_block_normal; + } + } + + if (history_mode == hist_normal){ + file->state.undo.edit_history_cursor = file->state.undo.history.edit_count; + } +} + +inline void +file_pre_edit_maintenance(System_Functions *system, + General_Memory *general, + Editing_File *file){ + if (file->state.still_lexing){ + system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); + if (file->state.swap_stack.tokens){ + general_memory_free(general, file->state.swap_stack.tokens); + file->state.swap_stack.tokens = 0; + } + } + file->state.last_4ed_edit_time = system->time(); +} + +struct Cursor_Fix_Descriptor{ + b32 is_batch; + union{ + struct{ + Buffer_Edit *batch; + i32 batch_size; + }; + struct{ + i32 start, end; + i32 shift_amount; + }; + }; +}; + +internal void +file_edit_cursor_fix(System_Functions *system, + Partition *part, General_Memory *general, + Editing_File *file, Editing_Layout *layout, + Cursor_Fix_Descriptor desc){ + + Full_Cursor temp_cursor; + Temp_Memory cursor_temp = begin_temp_memory(part); + i32 cursor_max = layout->panel_max_count * 2; + Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max); + + f32 y_offset = 0, y_position = 0; + i32 cursor_count = 0; + + View *view; + Panel *panel, *used_panels; + used_panels = &layout->used_sentinel; + + for (dll_items(panel, used_panels)){ + view = panel->view; + if (view->file == file){ + view_measure_wraps(system, general, view); + write_cursor_with_index(cursors, &cursor_count, view->cursor.pos); + write_cursor_with_index(cursors, &cursor_count, view->mark - 1); + write_cursor_with_index(cursors, &cursor_count, view->scroll_i - 1); + } + } + + if (cursor_count > 0){ + buffer_sort_cursors(cursors, cursor_count); + if (desc.is_batch){ + buffer_batch_edit_update_cursors(cursors, cursor_count, + desc.batch, desc.batch_size); + } + else{ + buffer_update_cursors(cursors, cursor_count, + desc.start, desc.end, + desc.shift_amount + (desc.end - desc.start)); + } + buffer_unsort_cursors(cursors, cursor_count); + + cursor_count = 0; + for (dll_items(panel, used_panels)){ + view = panel->view; + if (view && view->file == file){ + view_cursor_move(view, cursors[cursor_count++].pos); + view->preferred_x = view_get_cursor_x(view); + + view->mark = cursors[cursor_count++].pos + 1; + i32 new_scroll_i = cursors[cursor_count++].pos + 1; + if (view->scroll_i != new_scroll_i){ + view->scroll_i = new_scroll_i; + temp_cursor = view_compute_cursor_from_pos(view, view->scroll_i); + y_offset = MOD(view->scroll_y, view->font_height); + + if (view->unwrapped_lines){ + y_position = temp_cursor.unwrapped_y + y_offset; + view->target_y += (y_position - view->scroll_y); + view->scroll_y = y_position; + } + else{ + y_position = temp_cursor.wrapped_y + y_offset; + view->target_y += (y_position - view->scroll_y); + view->scroll_y = y_position; + } + } + } + } + } + + end_temp_memory(cursor_temp); +} + +internal void +file_do_single_edit(System_Functions *system, + Models *models, Editing_File *file, + Edit_Spec spec, History_Mode history_mode, b32 use_high_permission = 0){ + ProfileMomentFunction(); + if (!use_high_permission && file->settings.read_only) return; + + Mem_Options *mem = &models->mem; + Editing_Layout *layout = &models->layout; + + // NOTE(allen): fixing stuff beforewards???? + file_update_history_before_edit(mem, file, spec.step, spec.str, history_mode); + file_pre_edit_maintenance(system, &mem->general, file); + + // NOTE(allen): actual text replacement + i32 shift_amount = 0; + General_Memory *general = &mem->general; + Partition *part = &mem->part; + + char *str = (char*)spec.str; + i32 start = spec.step.edit.start; + i32 end = spec.step.edit.end; + i32 str_len = spec.step.edit.len; + + i32 scratch_size = partition_remaining(part); + + Assert(scratch_size > 0); + i32 request_amount = 0; + while (buffer_replace_range(&file->state.buffer, start, end, str, str_len, &shift_amount, + part->base + part->pos, scratch_size, &request_amount)){ + void *new_data = 0; + if (request_amount > 0){ + new_data = general_memory_allocate(general, request_amount, BUBBLE_BUFFER); + } + void *old_data = buffer_edit_provide_memory(&file->state.buffer, new_data, request_amount); + if (old_data) general_memory_free(general, old_data); + } + + Buffer_Type *buffer = &file->state.buffer; + i32 line_start = buffer_get_line_index(&file->state.buffer, start); + i32 line_end = buffer_get_line_index(&file->state.buffer, end); + i32 replaced_line_count = line_end - line_start; + i32 new_line_count = buffer_count_newlines(&file->state.buffer, start, start+str_len); + i32 line_shift = new_line_count - replaced_line_count; + + Render_Font *font = get_font_info(models->font_set, file->state.font_id)->font; + + file_grow_starts_widths_as_needed(general, buffer, line_shift); + buffer_remeasure_starts(buffer, line_start, line_end, line_shift, shift_amount); + buffer_remeasure_widths(buffer, font->advance_data, line_start, line_end, line_shift); + + Panel *panel, *used_panels; + used_panels = &layout->used_sentinel; + + for (dll_items(panel, used_panels)){ + View *view = panel->view; + if (view->file == file){ + view_measure_wraps(system, general, view); + } + } + +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + // NOTE(allen): fixing stuff afterwards + if (file->settings.tokens_exist) + file_relex_parallel(system, mem, file, start, end, shift_amount); +#endif + + Cursor_Fix_Descriptor desc = {}; + desc.start = start; + desc.end = end; + desc.shift_amount = shift_amount; + + file_edit_cursor_fix(system, part, general, + file, layout, desc); +} + +internal void +file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File *file, + Edit_Spec spec, History_Mode history_mode, b32 use_high_permission = 0){ + ProfileMomentFunction(); + if (!use_high_permission && file->settings.read_only) return; + + Mem_Options *mem = &models->mem; + Editing_Layout *layout = &models->layout; + + // NOTE(allen): fixing stuff "beforewards"??? + Assert(spec.str == 0); + file_update_history_before_edit(mem, file, spec.step, 0, history_mode); + file_pre_edit_maintenance(system, &mem->general, file); + + // NOTE(allen): actual text replacement + General_Memory *general = &mem->general; + Partition *part = &mem->part; + + u8 *str_base = file->state.undo.children.strings; + i32 batch_size = spec.step.child_count; + Buffer_Edit *batch = file->state.undo.children.edits + spec.step.first_child; + + Assert(spec.step.first_child < file->state.undo.children.edit_count); + Assert(batch_size >= 0); + + i32 scratch_size = partition_remaining(part); + Buffer_Batch_State state = {}; + i32 request_amount; + while (buffer_batch_edit_step(&state, &file->state.buffer, batch, + (char*)str_base, batch_size, part->base + part->pos, + scratch_size, &request_amount)){ + void *new_data = 0; + if (request_amount > 0){ + new_data = general_memory_allocate(general, request_amount, BUBBLE_BUFFER); + } + void *old_data = buffer_edit_provide_memory(&file->state.buffer, new_data, request_amount); + if (old_data) general_memory_free(general, old_data); + } + + // NOTE(allen): meta data + { + Buffer_Measure_Starts state = {}; + Render_Font *font = get_font_info(models->font_set, file->state.font_id)->font; + float *advance_data = 0; + if (font) advance_data = font->advance_data; + buffer_measure_starts_widths(&state, &file->state.buffer, advance_data); + } + + // NOTE(allen): cursor fixing + { + Cursor_Fix_Descriptor desc = {}; + desc.is_batch = 1; + desc.batch = batch; + desc.batch_size = batch_size; + + file_edit_cursor_fix(system, part, general, file, layout, desc); + } + + // NOTE(allen): token fixing + if (file->state.tokens_complete){ + Cpp_Token_Stack tokens = file->state.token_stack; + Cpp_Token *token = tokens.tokens; + Cpp_Token *end_token = tokens.tokens + tokens.count; + + Buffer_Edit *edit = batch; + Buffer_Edit *end_edit = batch + batch_size; + + i32 shift_amount = 0; + i32 local_shift = 0; + + for (; token < end_token && edit < end_edit; ++edit){ + local_shift = (edit->len - (edit->end - edit->start)); + for (; token->start < edit->start && edit->start < token->start + token->size && + token < end_token; ++token){ + token->size += local_shift; + } + for (; token->start < edit->start && token < end_token; ++token){ + token->start += shift_amount; + } + shift_amount += local_shift; + } + for (; token < end_token; ++token){ + token->start += shift_amount; + } + } +} + +inline void +file_replace_range(System_Functions *system, Models *models, Editing_File *file, + i32 start, i32 end, char *str, i32 len, i32 next_cursor, b32 use_high_permission = 0){ + Edit_Spec spec = {}; + spec.step.type = ED_NORMAL; + spec.step.edit.start = start; + spec.step.edit.end = end; + spec.step.edit.len = len; + spec.step.pre_pos = file->state.cursor_pos; + spec.step.post_pos = next_cursor; + spec.str = (u8*)str; + file_do_single_edit(system, models, file, spec, hist_normal, use_high_permission); +} + +inline void +view_replace_range(System_Functions *system, Models *models, View *view, + i32 start, i32 end, char *str, i32 len, i32 next_cursor){ + file_replace_range(system, models, view->file, start, end, str, len, next_cursor); +} + +inline void +view_post_paste_effect(View *view, i32 ticks, i32 start, i32 size, u32 color){ + Editing_File *file = view->file; + + file->state.paste_effect.start = start; + file->state.paste_effect.end = start + size; + file->state.paste_effect.color = color; + file->state.paste_effect.tick_down = ticks; + file->state.paste_effect.tick_max = ticks; +} + +internal void +view_undo_redo(System_Functions *system, + Models *models, View *view, + Edit_Stack *stack, Edit_Type expected_type){ + Editing_File *file = view->file; + + if (stack->edit_count > 0){ + Edit_Step step = stack->edits[stack->edit_count-1]; + + Assert(step.type == expected_type); + + Edit_Spec spec = {}; + spec.step = step; + + if (step.child_count == 0){ + spec.step.edit.str_start = 0; + spec.str = stack->strings + step.edit.str_start; + + file_do_single_edit(system, models, file, spec, hist_normal); + + if (expected_type == ED_UNDO) view_cursor_move(view, step.pre_pos); + else view_cursor_move(view, step.post_pos); + view->mark = view->cursor.pos; + + view_post_paste_effect(view, 10, step.edit.start, step.edit.len, + models->style.main.undo_color); + } + else{ + TentativeAssert(spec.step.special_type == 1); + file_do_white_batch_edit(system, models, view->file, spec, hist_normal); + } + } +} + +inline void +view_undo(System_Functions *system, Models *models, View *view){ + view_undo_redo(system, models, view, &view->file->state.undo.undo, ED_UNDO); +} + +inline void +view_redo(System_Functions *system, Models *models, View *view){ + view_undo_redo(system, models, view, &view->file->state.undo.redo, ED_REDO); +} + +inline u8* +write_data(u8 *ptr, void *x, i32 size){ + memcpy(ptr, x, size); + return (ptr + size); +} + +#define UseFileHistoryDump 0 + +#if UseFileHistoryDump +internal void +file_dump_history(System_Functions *system, Mem_Options *mem, Editing_File *file, char *filename){ + if (!file->state.undo.undo.edits) return; + + i32 size = 0; + + size += sizeof(i32); + size += file->state.undo.undo.edit_count*sizeof(Edit_Step); + size += sizeof(i32); + size += file->state.undo.redo.edit_count*sizeof(Edit_Step); + size += sizeof(i32); + size += file->state.undo.history.edit_count*sizeof(Edit_Step); + size += sizeof(i32); + size += file->state.undo.children.edit_count*sizeof(Buffer_Edit); + + size += sizeof(i32); + size += file->state.undo.undo.size; + size += sizeof(i32); + size += file->state.undo.redo.size; + size += sizeof(i32); + size += file->state.undo.history.size; + size += sizeof(i32); + size += file->state.undo.children.size; + + Partition *part = &mem->part; + i32 remaining = partition_remaining(part); + if (size < remaining){ + u8 *data, *curs; + data = (u8*)part->base + part->pos; + curs = data; + curs = write_data(curs, &file->state.undo.undo.edit_count, 4); + curs = write_data(curs, &file->state.undo.redo.edit_count, 4); + curs = write_data(curs, &file->state.undo.history.edit_count, 4); + curs = write_data(curs, &file->state.undo.children.edit_count, 4); + curs = write_data(curs, &file->state.undo.undo.size, 4); + curs = write_data(curs, &file->state.undo.redo.size, 4); + curs = write_data(curs, &file->state.undo.history.size, 4); + curs = write_data(curs, &file->state.undo.children.size, 4); + + curs = write_data(curs, file->state.undo.undo.edits, sizeof(Edit_Step)*file->state.undo.undo.edit_count); + curs = write_data(curs, file->state.undo.redo.edits, sizeof(Edit_Step)*file->state.undo.redo.edit_count); + curs = write_data(curs, file->state.undo.history.edits, sizeof(Edit_Step)*file->state.undo.history.edit_count); + curs = write_data(curs, file->state.undo.children.edits, sizeof(Buffer_Edit)*file->state.undo.children.edit_count); + + curs = write_data(curs, file->state.undo.undo.strings, file->state.undo.undo.size); + curs = write_data(curs, file->state.undo.redo.strings, file->state.undo.redo.size); + curs = write_data(curs, file->state.undo.history.strings, file->state.undo.history.size); + curs = write_data(curs, file->state.undo.children.strings, file->state.undo.children.size); + + Assert((i32)(curs - data) == size); + system->save_file(filename, data, size); + } +} +#endif + +internal void +view_history_step(System_Functions *system, Models *models, View *view, History_Mode history_mode){ + Assert(history_mode != hist_normal); + + Editing_File *file = view->file; + + b32 do_history_step = 0; + Edit_Step step = {}; + if (history_mode == hist_backward){ + if (file->state.undo.edit_history_cursor > 0){ + do_history_step = 1; + step = file->state.undo.history.edits[--file->state.undo.edit_history_cursor]; + } + } + else{ + if (file->state.undo.edit_history_cursor < file->state.undo.history.edit_count){ + Assert(((file->state.undo.history.edit_count - file->state.undo.edit_history_cursor) & 1) == 0); + step = file->state.undo.history.edits[--file->state.undo.history.edit_count]; + file->state.undo.history.size -= step.edit.len; + ++file->state.undo.edit_history_cursor; + do_history_step = 1; + } + } + + if (do_history_step){ + Edit_Spec spec; + spec.step = step; + + if (spec.step.child_count == 0){ + spec.step.edit.str_start = 0; + spec.str = file->state.undo.history.strings + step.edit.str_start; + + file_do_single_edit(system, models, file, spec, history_mode); + + switch (spec.step.type){ + case ED_NORMAL: + case ED_REDO: + view_cursor_move(view, step.post_pos); + break; + + case ED_REVERSE_NORMAL: + case ED_UNDO: + view_cursor_move(view, step.pre_pos); + break; + } + view->mark = view->cursor.pos; + } + else{ + TentativeAssert(spec.step.special_type == 1); + file_do_white_batch_edit(system, models, view->file, spec, history_mode); + } + } +} + +// TODO(allen): write these as streamed operations +internal i32 +view_find_end_of_line(View *view, i32 pos){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + Editing_File *file = view->file; + char *data = file->state.buffer.data; + while (pos < file->state.buffer.size && data[pos] != '\n') ++pos; + if (pos > file->state.buffer.size) pos = file->state.buffer.size; +#endif + return pos; +} + +internal i32 +view_find_beginning_of_line(View *view, i32 pos){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + Editing_File *file = view->file; + char *data = file->state.buffer.data; + if (pos > 0){ + --pos; + while (pos > 0 && data[pos] != '\n') --pos; + if (pos != 0) ++pos; + } +#endif + return pos; +} + +internal i32 +view_find_beginning_of_next_line(View *view, i32 pos){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + Editing_File *file = view->file; + char *data = file->state.buffer.data; + while (pos < file->state.buffer.size && + !starts_new_line(data[pos])){ + ++pos; + } + if (pos < file->state.buffer.size){ + ++pos; + } +#endif + return pos; +} + +internal String* +working_set_next_clipboard_string(General_Memory *general, Working_Set *working, i32 str_size){ + String *result = 0; + i32 clipboard_current = working->clipboard_current; + if (working->clipboard_size == 0){ + clipboard_current = 0; + working->clipboard_size = 1; + } + else{ + ++clipboard_current; + if (clipboard_current >= working->clipboard_max_size){ + clipboard_current = 0; + } + else if (working->clipboard_size <= clipboard_current){ + working->clipboard_size = clipboard_current+1; + } + } + result = &working->clipboards[clipboard_current]; + working->clipboard_current = clipboard_current; + working->clipboard_rolling = clipboard_current; + char *new_str; + if (result->str){ + new_str = (char*)general_memory_reallocate(general, result->str, result->size, str_size); + } + else{ + new_str = (char*)general_memory_allocate(general, str_size+1); + } + // TODO(allen): What if new_str == 0? + *result = make_string(new_str, 0, str_size); + return result; +} + +internal String* +working_set_clipboard_head(Working_Set *working){ + String *result = 0; + if (working->clipboard_size > 0){ + i32 clipboard_index = working->clipboard_current; + working->clipboard_rolling = clipboard_index; + result = &working->clipboards[clipboard_index]; + } + return result; +} + +internal String* +working_set_clipboard_roll_down(Working_Set *working){ + String *result = 0; + if (working->clipboard_size > 0){ + i32 clipboard_index = working->clipboard_rolling; + --clipboard_index; + if (clipboard_index < 0){ + clipboard_index = working->clipboard_size-1; + } + working->clipboard_rolling = clipboard_index; + result = &working->clipboards[clipboard_index]; + } + return result; +} + +internal void +clipboard_copy(System_Functions *system, General_Memory *general, Working_Set *working, Range range, Editing_File *file){ + i32 size = range.end - range.start; + String *dest = working_set_next_clipboard_string(general, working, size); + buffer_stringify(&file->state.buffer, range.start, range.end, dest->str); + dest->size = size; + system->post_clipboard(*dest); +} + +internal Edit_Spec +file_compute_whitespace_edit(Mem_Options *mem, Editing_File *file, i32 cursor_pos, + Buffer_Edit *edits, char *str_base, i32 str_size, + Buffer_Edit *inverse_array, char *inv_str, i32 inv_max, + i32 edit_count){ + General_Memory *general = &mem->general; + + i32 inv_str_pos = 0; + Buffer_Invert_Batch state = {}; + if (buffer_invert_batch(&state, &file->state.buffer, edits, edit_count, + inverse_array, inv_str, &inv_str_pos, inv_max)) + Assert(0); + + i32 first_child = + undo_children_push(general, &file->state.undo.children, + edits, edit_count, (u8*)(str_base), str_size); + i32 inverse_first_child = + undo_children_push(general, &file->state.undo.children, + inverse_array, edit_count, (u8*)(inv_str), inv_str_pos); + + Edit_Spec spec = {}; + spec.step.type = ED_NORMAL; + spec.step.first_child = first_child; + spec.step.inverse_first_child = inverse_first_child; + spec.step.special_type = 1; + spec.step.child_count = edit_count; + spec.step.inverse_child_count = edit_count; + spec.step.pre_pos = cursor_pos; + spec.step.post_pos = cursor_pos; + + return spec; +} + +internal void +view_clean_whitespace(System_Functions *system, Models *models, View *view){ + Mem_Options *mem = &models->mem; + Editing_File *file = view->file; + + Partition *part = &mem->part; + i32 line_count = file->state.buffer.line_count; + i32 edit_max = line_count * 2; + i32 edit_count = 0; + + Assert(file && !file->state.is_dummy); + + Temp_Memory temp = begin_temp_memory(part); + Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max); + + char *str_base = (char*)part->base + part->pos; + i32 str_size = 0; + for (i32 line_i = 0; line_i < line_count; ++line_i){ + i32 start = file->state.buffer.line_starts[line_i]; + i32 preferred_indentation; + b32 all_whitespace = 0; + b32 all_space = 0; + i32 hard_start = + buffer_find_hard_start(&file->state.buffer, start, &all_whitespace, &all_space, + &preferred_indentation, 4); + + if (all_whitespace) preferred_indentation = 0; + + if ((all_whitespace && hard_start > start) || !all_space){ + Buffer_Edit new_edit; + new_edit.str_start = str_size; + str_size += preferred_indentation; + char *str = push_array(part, char, preferred_indentation); + for (i32 j = 0; j < preferred_indentation; ++j) str[j] = ' '; + new_edit.len = preferred_indentation; + new_edit.start = start; + new_edit.end = hard_start; + edits[edit_count++] = new_edit; + } + Assert(edit_count <= edit_max); + } + + if (edit_count > 0){ + Assert(buffer_batch_debug_sort_check(edits, edit_count)); + + // NOTE(allen): computing edit spec, doing batch edit + Buffer_Edit *inverse_array = push_array(part, Buffer_Edit, edit_count); + Assert(inverse_array); + + char *inv_str = (char*)part->base + part->pos; + Edit_Spec spec = + file_compute_whitespace_edit(mem, file, view->cursor.pos, edits, str_base, str_size, + inverse_array, inv_str, part->max - part->pos, edit_count); + + file_do_white_batch_edit(system, models, view->file, spec, hist_normal); + } + + end_temp_memory(temp); +} + +internal void +view_auto_tab_tokens(System_Functions *system, + Models *models, View *view, + i32 start, i32 end, b32 empty_blank_lines){ +#if BUFFER_EXPERIMENT_SCALPEL <= 0 + Editing_File *file = view->file; + Mem_Options *mem = &models->mem; + Partition *part = &mem->part; + Buffer *buffer = &file->state.buffer; + + Assert(file && !file->state.is_dummy); + Cpp_Token_Stack tokens = file->state.token_stack; + Assert(tokens.tokens); + + i32 line_start = buffer_get_line_index(buffer, start); + i32 line_end = buffer_get_line_index(buffer, end) + 1; + + i32 edit_max = (line_end - line_start) * 2; + i32 edit_count = 0; + + i32 indent_mark_count = line_end - line_start; + + Temp_Memory temp = begin_temp_memory(part); + i32 *indent_marks = push_array(part, i32, indent_mark_count); + { + i32 current_indent = 0; + i32 token_i; + Cpp_Token *token, *self_token; + + { + i32 start_pos = file->state.buffer.line_starts[line_start]; + Cpp_Get_Token_Result result = cpp_get_token(&tokens, start_pos); + token_i = result.token_index; + if (result.in_whitespace) token_i += 1; + self_token = tokens.tokens + token_i; + } + + i32 line = line_start - 1; + for (; line >= 0; --line){ + i32 start = file->state.buffer.line_starts[line]; + b32 all_whitespace = 0; + b32 all_space = 0; + buffer_find_hard_start(&file->state.buffer, start, + &all_whitespace, &all_space, ¤t_indent, 4); + if (!all_whitespace) break; + } + + if (line < 0){ + token_i = 0; + token = tokens.tokens + token_i; + } + else{ + i32 start_pos = file->state.buffer.line_starts[line]; + Cpp_Get_Token_Result result = cpp_get_token(&tokens, start_pos); + token_i = result.token_index; + if (result.in_whitespace) token_i += 1; + token = tokens.tokens + token_i; + + while (token >= tokens.tokens && + token->flags & CPP_TFLAG_PP_DIRECTIVE || + token->flags & CPP_TFLAG_PP_BODY){ + --token; + } + + if (token < tokens.tokens){ + ++token; + current_indent = 0; + } + else if (token->start < start_pos){ + line = buffer_get_line_index(&file->state.buffer, token->start); + i32 start = file->state.buffer.line_starts[line]; + b32 all_whitespace = 0; + b32 all_space = 0; + buffer_find_hard_start(&file->state.buffer, start, + &all_whitespace, &all_space, ¤t_indent, 4); + Assert(!all_whitespace); + } + } + + indent_marks -= line_start; + i32 line_i = line_start; + i32 next_line_start = file->state.buffer.line_starts[line_i]; + switch (token->type){ + case CPP_TOKEN_BRACKET_OPEN: current_indent += 4; break; + case CPP_TOKEN_PARENTHESE_OPEN: current_indent += 4; break; + case CPP_TOKEN_BRACE_OPEN: current_indent += 4; break; + } + + Cpp_Token *prev_token = token; + ++token; + for (; line_i < line_end; ++token_i, ++token){ + for (; token->start >= next_line_start && line_i < line_end;){ + i32 this_line_start = next_line_start; + next_line_start = file->state.buffer.line_starts[line_i+1]; + i32 this_indent; + if (prev_token && prev_token->type == CPP_TOKEN_COMMENT && + prev_token->start <= this_line_start && prev_token->start + prev_token->size > this_line_start){ + this_indent = -1; + } + else{ + this_indent = current_indent; + if (token->start < next_line_start){ + if (token->flags & CPP_TFLAG_PP_DIRECTIVE) this_indent = 0; + else{ + switch (token->type){ + case CPP_TOKEN_BRACKET_CLOSE: this_indent -= 4; break; + case CPP_TOKEN_PARENTHESE_CLOSE: this_indent -= 4; break; + case CPP_TOKEN_BRACE_CLOSE: this_indent -= 4; break; + case CPP_TOKEN_BRACE_OPEN: break; + default: + if (current_indent > 0 && prev_token){ + if (!(prev_token->flags & CPP_TFLAG_PP_BODY || + prev_token->flags & CPP_TFLAG_PP_DIRECTIVE)){ + switch (prev_token->type){ + case CPP_TOKEN_BRACKET_OPEN: case CPP_TOKEN_PARENTHESE_OPEN: + case CPP_TOKEN_BRACE_OPEN: case CPP_TOKEN_BRACE_CLOSE: + case CPP_TOKEN_SEMICOLON: case CPP_TOKEN_COLON: break; + case CPP_TOKEN_COMMA: case CPP_TOKEN_COMMENT: break; + default: this_indent += 4; + } + } + } + } + } + } + if (this_indent < 0) this_indent = 0; + } + indent_marks[line_i] = this_indent; + ++line_i; + } + + switch (token->type){ + case CPP_TOKEN_BRACKET_OPEN: current_indent += 4; break; + case CPP_TOKEN_BRACKET_CLOSE: current_indent -= 4; break; + case CPP_TOKEN_PARENTHESE_OPEN: current_indent += 4; break; + case CPP_TOKEN_PARENTHESE_CLOSE: current_indent -= 4; break; + case CPP_TOKEN_BRACE_OPEN: current_indent += 4; break; + case CPP_TOKEN_BRACE_CLOSE: current_indent -= 4; break; + } + prev_token = token; + } + } + + Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max); + + char *str_base = (char*)part->base + part->pos; + i32 str_size = 0; + for (i32 line_i = line_start; line_i < line_end; ++line_i){ + i32 start = file->state.buffer.line_starts[line_i]; + i32 preferred_indentation; + i32 correct_indentation; + b32 all_whitespace = 0; + b32 all_space = 0; + i32 hard_start = + buffer_find_hard_start(&file->state.buffer, start, &all_whitespace, &all_space, + &preferred_indentation, 4); + + correct_indentation = indent_marks[line_i]; + if (all_whitespace && empty_blank_lines) correct_indentation = 0; + if (correct_indentation == -1) correct_indentation = preferred_indentation; + + if ((all_whitespace && hard_start > start) || !all_space || correct_indentation != preferred_indentation){ + Buffer_Edit new_edit; + new_edit.str_start = str_size; + str_size += correct_indentation; + char *str = push_array(part, char, correct_indentation); + for (i32 j = 0; j < correct_indentation; ++j) str[j] = ' '; + new_edit.len = correct_indentation; + new_edit.start = start; + new_edit.end = hard_start; + edits[edit_count++] = new_edit; + } + + Assert(edit_count <= edit_max); + } + + if (edit_count > 0){ + Assert(buffer_batch_debug_sort_check(edits, edit_count)); + + // NOTE(allen): computing edit spec, doing batch edit + Buffer_Edit *inverse_array = push_array(part, Buffer_Edit, edit_count); + Assert(inverse_array); + + char *inv_str = (char*)part->base + part->pos; + Edit_Spec spec = + file_compute_whitespace_edit(mem, file, view->cursor.pos, edits, str_base, str_size, + inverse_array, inv_str, part->max - part->pos, edit_count); + + file_do_white_batch_edit(system, models, view->file, spec, hist_normal); + } + + { + b32 all_whitespace = 0; + b32 all_space = 0; + i32 preferred_indentation; + i32 start = view->cursor.pos; + i32 hard_start = buffer_find_hard_start( + &file->state.buffer, start, &all_whitespace, &all_space, + &preferred_indentation, 4); + + view_cursor_move(view, hard_start); + } + + end_temp_memory(temp); +#endif +} + +struct Get_Link_Result{ + b32 in_link; + i32 index; +}; + +internal u32* +style_get_color(Style *style, Cpp_Token token){ + u32 *result; + if (token.flags & CPP_TFLAG_IS_KEYWORD){ + if (token.type == CPP_TOKEN_BOOLEAN_CONSTANT){ + result = &style->main.bool_constant_color; + } + else{ + result = &style->main.keyword_color; + } + } + else if(token.flags & CPP_TFLAG_PP_DIRECTIVE){ + result = &style->main.preproc_color; + } + else{ + switch (token.type){ + case CPP_TOKEN_COMMENT: + result = &style->main.comment_color; + break; + + case CPP_TOKEN_STRING_CONSTANT: + result = &style->main.str_constant_color; + break; + + case CPP_TOKEN_CHARACTER_CONSTANT: + result = &style->main.char_constant_color; + break; + + case CPP_TOKEN_INTEGER_CONSTANT: + result = &style->main.int_constant_color; + break; + + case CPP_TOKEN_FLOATING_CONSTANT: + result = &style->main.float_constant_color; + break; + + case CPP_TOKEN_INCLUDE_FILE: + result = &style->main.include_color; + break; + + default: + result = &style->main.default_color; + } + } + return result; +} + +inline f32 +view_compute_max_target_y(i32 lowest_line, i32 line_height, real32 view_height){ + real32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f; + return max_target_y; +} + +internal real32 +view_compute_max_target_y(View *view){ + i32 lowest_line = view_compute_lowest_line(view); + i32 line_height = view->font_height; + real32 view_height = view_compute_height(view); + real32 max_target_y = view_compute_max_target_y( + lowest_line, line_height, view_height); + return max_target_y; +} + +internal void +remeasure_file_view(System_Functions *system, View *view, i32_Rect rect){ + if (file_is_ready(view->file)){ + Relative_Scrolling relative = view_get_relative_scrolling(view); + view_measure_wraps(system, &view->models->mem.general, view); + view_cursor_move(view, view->cursor.pos); + view->preferred_x = view_get_cursor_x(view); + view_set_relative_scrolling(view, relative); + } +} + +internal void +undo_shit(System_Functions *system, View *view, UI_State *state, UI_Layout *layout, + i32 total_count, i32 undo_count, i32 scrub_max){ + + Editing_File *file = view->file; + + if (view->widget.timeline.undo_line){ + if (do_button(1, state, layout, "- Undo", 1)){ + view->widget.timeline.undo_line = 0; + } + + if (view->widget.timeline.undo_line){ + Widget_ID wid = make_id(state, 2); + i32 new_count; + if (do_undo_slider(wid, state, layout, total_count, undo_count, 0, &new_count)){ + for (i32 i = 0; i < scrub_max && new_count < undo_count; ++i){ + view_undo(system, view->models, view); + --undo_count; + } + for (i32 i = 0; i < scrub_max && new_count > undo_count; ++i){ + view_redo(system, view->models, view); + ++undo_count; + } + } + } + } + else{ + if (do_button(1, state, layout, "+ Undo", 1)){ + view->widget.timeline.undo_line = 1; + } + } + + if (view->widget.timeline.history_line){ + if (do_button(3, state, layout, "- History", 1)){ + view->widget.timeline.history_line = 0; + } + + Widget_ID wid = make_id(state, 4); + if (view->widget.timeline.history_line){ + i32 new_count; + i32 mid = ((file->state.undo.history.edit_count + file->state.undo.edit_history_cursor) >> 1); + i32 count = file->state.undo.edit_history_cursor; + if (do_undo_slider(wid, state, layout, mid, count, &file->state.undo, &new_count)){ + for (i32 i = 0; i < scrub_max && new_count < count; ++i){ + view_history_step(system, view->models, view, hist_backward); + } + for (i32 i = 0; i < scrub_max && new_count > count; ++i){ + view_history_step(system, view->models, view, hist_forward); + } + } + } + } + else{ + if (do_button(3, state, layout, "+ History", 1)){ + view->widget.timeline.history_line = 1; + } + } +} + +internal void +draw_file_view_queries(View *view, UI_State *state, UI_Layout *layout){ + Widget_ID wid; + Query_Slot *slot; + Query_Bar *bar; + i32 i = 1; + + for (slot = view->query_set.used_slot; slot != 0; slot = slot->next){ + wid = make_id(state, i++); + bar = slot->query_bar; + do_text_field(wid, state, layout, bar->prompt, bar->string); + } +} + +inline void +view_show_menu(View *fview, Command_Map *gui_map){ + fview->ui_state = {}; + fview->map_for_file = fview->map; + fview->map = gui_map; + fview->showing_ui = VUI_Menu; +} + +inline void +view_show_config(View *fview, Command_Map *gui_map){ + fview->ui_state = {}; + fview->map_for_file = fview->map; + fview->map = gui_map; + fview->showing_ui = VUI_Config; +} + +inline void +view_show_interactive(System_Functions *system, View *view, Command_Map *gui_map, + Interactive_Action action, Interactive_Interaction interaction, String query){ + + Models *models = view->models; + + view->ui_state = {}; + view->map_for_file = view->map; + view->map = gui_map; + view->showing_ui = VUI_Interactive; + view->action = action; + view->interaction = interaction; + view->finished = 0; + + copy(&view->query, query); + view->dest.str[0] = 0; + view->dest.size = 0; + + hot_directory_clean_end(&models->hot_directory); + hot_directory_reload(system, &models->hot_directory, &models->working_set); +} + +inline void +view_show_theme(View *view, Command_Map *gui_map){ + view->ui_state = {}; + view->map_for_file = view->map; + view->map = gui_map; + view->showing_ui = VUI_Theme; + view->color_mode = CV_Mode_Library; + view->color = super_color_create(0xFF000000); +} + +inline void +view_show_file(View *view, Command_Map *file_map){ + view->ui_state = {}; + if (file_map){ + view->map = file_map; + } + else{ + view->map = view->map_for_file; + } + view->showing_ui = VUI_None; +} + +internal void +interactive_view_complete(View *view){ + Models *models = view->models; + Panel *panel = view->panel; + Editing_File *old_file = view->file; + + switch (view->action){ + case IAct_Open: + delayed_open(&models->delay1, models->hot_directory.string, panel); + delayed_touch_file(&models->delay1, old_file); + break; + + case IAct_Save_As: + delayed_save_as(&models->delay1, models->hot_directory.string, panel); + break; + + case IAct_New: + if (models->hot_directory.string.size > 0 && + !char_is_slash(models->hot_directory.string.str[models->hot_directory.string.size-1])){ + delayed_new(&models->delay1, models->hot_directory.string, panel); + } + break; + + case IAct_Switch: + delayed_switch(&models->delay1, view->dest, panel); + delayed_touch_file(&models->delay1, old_file); + break; + + case IAct_Kill: + delayed_try_kill(&models->delay1, view->dest); + break; + + case IAct_Sure_To_Kill: + switch (view->user_action){ + case 0: + delayed_kill(&models->delay1, view->dest); + break; + + case 1: + break; + + case 2: + // TODO(allen): This is fishy! What if the save doesn't happen this time around? + // We need to ensure delayed acts happen in order I think. + delayed_save(&models->delay1, view->dest); + delayed_kill(&models->delay1, view->dest); + break; + } + break; + } + view_show_file(view, 0); + + // TODO(allen): This is here to prevent the key press from being passed to the + // underlying file which is a giant pain. + view->file = 0; +} + +internal void +update_highlighting(View *view){ + View *file_view = view->hot_file_view; + if (!file_view){ + view->highlight = {}; + return; + } + + Editing_File *file = file_view->file; + if (!file || !file_is_ready(file)){ + view->highlight = {}; + return; + } + + Models *models = view->models; + + Style *style = &models->style; + i32 pos = view_get_cursor_pos(file_view); + char c = buffer_get_char(&file->state.buffer, pos); + + if (c == '\r'){ + view->highlight.ids[0] = + raw_ptr_dif(&style->main.special_character_color, style); + } + + else if (file->state.tokens_complete){ + Cpp_Token_Stack *tokens = &file->state.token_stack; + Cpp_Get_Token_Result result = cpp_get_token(tokens, pos); + Cpp_Token token = tokens->tokens[result.token_index]; + if (!result.in_whitespace){ + u32 *color = style_get_color(style, token); + view->highlight.ids[0] = raw_ptr_dif(color, style); + if (token.type == CPP_TOKEN_JUNK){ + view->highlight.ids[1] = + raw_ptr_dif(&style->main.highlight_junk_color, style); + } + else if (char_is_whitespace(c)){ + view->highlight.ids[1] = + raw_ptr_dif(&style->main.highlight_white_color, style); + } + else{ + view->highlight.ids[1] = 0; + } + } + else{ + view->highlight.ids[0] = 0; + view->highlight.ids[1] = + raw_ptr_dif(&style->main.highlight_white_color, style); + } + } + + else{ + if (char_is_whitespace(c)){ + view->highlight.ids[0] = 0; + view->highlight.ids[1] = + raw_ptr_dif(&style->main.highlight_white_color, style); + } + else{ + view->highlight.ids[0] = + raw_ptr_dif(&style->main.default_color, style); + view->highlight.ids[1] = 0; + } + } + + if (file_view->show_temp_highlight){ + view->highlight.ids[2] = + raw_ptr_dif(&style->main.highlight_color, style); + view->highlight.ids[3] = + raw_ptr_dif(&style->main.at_highlight_color, style); + } + else if (file->state.paste_effect.tick_down > 0){ + view->highlight.ids[2] = + raw_ptr_dif(&style->main.paste_color, style); + view->highlight.ids[3] = 0; + } + else{ + view->highlight.ids[2] = 0; + view->highlight.ids[3] = 0; + } +} + +internal b32 +theme_library_shit(System_Functions *system, Exchange *exchange, + View *view, UI_State *state, UI_Layout *layout){ + + Models *models = view->models; + Mem_Options *mem = &models->mem; + + i32 result = 0; + + Library_UI ui; + ui.state = state; + ui.layout = layout; + + ui.fonts = models->font_set; + ui.hot_directory = &models->hot_directory; + ui.styles = &models->styles; + + Color_View_Mode mode = view->color_mode; + + i32_Rect bar_rect = ui.layout->rect; + bar_rect.x0 = bar_rect.x1 - 20; + do_scroll_bar(ui.state, bar_rect); + + ui.layout->y -= FLOOR32(view->ui_state.view_y); + ui.layout->rect.x1 -= 20; + + b32 case_sensitive = 0; + + switch (mode){ + case CV_Mode_Library: + { + do_label(ui.state, ui.layout, literal("Current Theme - Click to Edit")); + if (do_style_preview(&ui, &models->style)){ + view->color_mode = CV_Mode_Adjusting; + view->ui_state.selected = {}; + ui.state->view_y = 0; + result = 1; + } + + begin_row(ui.layout, 3); + if (ui.state->style->name.size >= 1){ + if (do_button(-2, ui.state, ui.layout, "Save", 2)){ + //style_library_add(ui.styles, ui.state->style); + } + } + else{ + do_button(-2, ui.state, ui.layout, "~Need's Name~", 2); + } + if (do_button(-3, ui.state, ui.layout, "Import", 2)){ + view->color_mode = CV_Mode_Import_File; + hot_directory_clean_end(&models->hot_directory); + hot_directory_reload(system, &models->hot_directory, &models->working_set); + } + if (do_button(-4, ui.state, ui.layout, "Export", 2)){ + view->color_mode = CV_Mode_Export; + hot_directory_clean_end(&models->hot_directory); + hot_directory_reload(system, &models->hot_directory, &models->working_set); + memset(view->import_export_check, 0, sizeof(view->import_export_check)); + } + + do_label(ui.state, ui.layout, literal("Theme Library - Click to Select")); + + i32 style_count = models->styles.count; + Style *style = models->styles.styles; + for (i32 i = 0; i < style_count; ++i, ++style){ + if (do_style_preview(&ui, style)){ + style_copy(&models->style, style); + result = 1; + } + } + }break; + + case CV_Mode_Import_File: + { + do_label(ui.state, ui.layout, literal("Current Theme")); + do_style_preview(&ui, &models->style); + + b32 file_selected = 0; + + do_label(ui.state, ui.layout, literal("Import Which File?")); + begin_row(ui.layout, 2); + if (do_button(-2, ui.state, ui.layout, "*.p4c only", 2, 1, view->p4c_only)){ + view->p4c_only = !view->p4c_only; + } + if (do_button(-3, ui.state, ui.layout, "Cancel", 2)){ + view->color_mode = CV_Mode_Library; + } + + b32 new_dir = 0; + if (do_file_list_box(system, ui.state, ui.layout, + ui.hot_directory, view->p4c_only, 1, case_sensitive, + &new_dir, &file_selected, 0)){ + result = 1; + } + + if (new_dir){ + hot_directory_reload(system, ui.hot_directory, ui.state->working_set); + } + if (file_selected){ + memset(&view->inspecting_styles, 0, sizeof(Style_Library)); + memset(view->import_export_check, 1, + sizeof(view->import_export_check)); + + view->import_file_id = exchange_request_file(exchange, + models->hot_directory.string.str, + models->hot_directory.string.size); + view->color_mode = CV_Mode_Import_Wait; + + } + }break; + + case CV_Mode_Import_Wait: + { + Style *styles = view->inspecting_styles.styles; + Data file = {}; + i32 file_max = 0; + + i32 count = 0; + i32 max = ArrayCount(view->inspecting_styles.styles); + + AllowLocal(styles); + AllowLocal(max); + + if (exchange_file_ready(exchange, view->import_file_id, + &file.data, &file.size, &file_max)){ + if (file.data){ + if (0 /* && style_library_import(file, ui.fonts, styles, max, &count) */){ + view->color_mode = CV_Mode_Import; + } + else{ + view->color_mode = CV_Mode_Library; + } + view->inspecting_styles.count = count; + } + else{ + Assert(!"this shouldn't happen!"); + } + + exchange_free_file(exchange, view->import_file_id); + } + }break; + + case CV_Mode_Export_File: + { + do_label(ui.state, ui.layout, literal("Current Theme")); + do_style_preview(&ui, &models->style); + + b32 file_selected = 0; + + do_label(ui.state, ui.layout, literal("Export File Name?")); + begin_row(ui.layout, 2); + if (do_button(-2, ui.state, ui.layout, "Finish Export", 2)){ + file_selected = 1; + } + if (do_button(-3, ui.state, ui.layout, "Cancel", 2)){ + view->color_mode = CV_Mode_Library; + } + + b32 new_dir = 0; + if (do_file_list_box(system, ui.state, ui.layout, + ui.hot_directory, 1, 1, case_sensitive, + &new_dir, &file_selected, ".p4c")){ + result = 1; + } + + if (new_dir){ + hot_directory_reload(system, + ui.hot_directory, ui.state->working_set); + } + if (file_selected){ + i32 count = ui.styles->count; + Temp_Memory temp = begin_temp_memory(&mem->part); + Style **styles = push_array(&mem->part, Style*, sizeof(Style*)*count); + + Style *style = ui.styles->styles; + b8 *export_check = view->import_export_check; + i32 export_count = 0; + for (i32 i = 0; i < count; ++i, ++style){ + if (export_check[i]){ + styles[export_count++] = style; + } + } + char *data = push_array(&mem->part, char, ui.hot_directory->string.size + 5); + String str = make_string(data, 0, ui.hot_directory->string.size + 5); + copy(&str, ui.hot_directory->string); + append(&str, make_lit_string(".p4c")); + /*style_library_export(system, exchange, mem, &target->font_set, str.str, styles, export_count);*/ + + end_temp_memory(temp); + view->color_mode = CV_Mode_Library; + } + }break; + + case CV_Mode_Import: + { + do_label(ui.state, ui.layout, literal("Current Theme")); + do_style_preview(&ui, &models->style); + + i32 style_count = view->inspecting_styles.count; + Style *styles = view->inspecting_styles.styles; + b8 *import_check = view->import_export_check; + + do_label(ui.state, ui.layout, literal("Pack")); + begin_row(ui.layout, 2); + if (do_button(-2, ui.state, ui.layout, "Finish Import", 2)){ + Style *style = styles; + for (i32 i = 0; i < style_count; ++i, ++style){ + //if (import_check[i]) style_library_add(ui.styles, style); + } + view->color_mode = CV_Mode_Library; + } + if (do_button(-3, ui.state, ui.layout, "Cancel", 2)){ + view->color_mode = CV_Mode_Library; + } + + Style *style = styles; + for (i32 i = 0; i < style_count; ++i, ++style){ + if (do_style_preview(&ui, style, import_check[i])){ + import_check[i] = !import_check[i]; + result = 1; + } + } + }break; + + case CV_Mode_Export: + { + do_label(ui.state, ui.layout, literal("Current Theme")); + do_style_preview(&ui, &models->style); + + do_label(ui.state, ui.layout, literal("Export Which Themes?")); + begin_row(ui.layout, 2); + if (do_button(-2, ui.state, ui.layout, "Export", 2)){ + view->color_mode = CV_Mode_Export_File; + } + if (do_button(-3, ui.state, ui.layout, "Cancel", 2)){ + view->color_mode = CV_Mode_Library; + } + + i32 style_count = models->styles.count; + Style *style = models->styles.styles; + b8 *export_check = view->import_export_check; + for (i32 i = 0; i < style_count; ++i, ++style){ + if (do_style_preview(&ui, style, export_check[i])){ + export_check[i] = !export_check[i]; + result = 1; + } + } + }break; + } + + return (result); +} + +internal b32 +theme_adjusting_shit(View *view, UI_State *state, UI_Layout *layout, Super_Color *color){ + update_highlighting(view); + + Models *models = view->models; + + Style *style = &models->style; + i32 result = 0; + + Color_UI ui; + ui.state = state; + ui.layout = layout; + + ui.fonts = models->font_set; + ui.global_font = &models->global_font; + ui.highlight = view->highlight; + ui.color = view->color; + ui.has_hover_color = 0; + ui.state->sub_id1_change = 0; + ui.hex_advance = font_get_max_width(ui.fonts, ui.state->font_id, "0123456789abcdefx"); + ui.palette = models->palette; + ui.palette_size = models->palette_size; + + i32_Rect bar_rect = ui.layout->rect; + bar_rect.x0 = bar_rect.x1 - 20; + do_scroll_bar(ui.state, bar_rect); + + ui.layout->y -= FLOOR32(view->ui_state.view_y); + ui.layout->rect.x1 -= 20; + + if (do_button(-1, ui.state, ui.layout, "Back to Library", 2)){ + view->color_mode = CV_Mode_Library; + ui.state->view_y = 0; + } + + do_style_name(&ui); + do_font_switch(&ui); + + do_color_adjuster(&ui, &style->main.back_color, + style->main.default_color, style->main.back_color, + "Background"); + do_color_adjuster(&ui, &style->main.margin_color, + style->main.default_color, style->main.margin_color, + "Margin"); + do_color_adjuster(&ui, &style->main.margin_hover_color, + style->main.default_color, style->main.margin_hover_color, + "Margin Hover"); + do_color_adjuster(&ui, &style->main.margin_active_color, + style->main.default_color, style->main.margin_active_color, + "Margin Active"); + + do_color_adjuster(&ui, &style->main.cursor_color, + style->main.at_cursor_color, style->main.cursor_color, + "Cursor"); + do_color_adjuster(&ui, &style->main.at_cursor_color, + style->main.at_cursor_color, style->main.cursor_color, + "Text At Cursor"); + do_color_adjuster(&ui, &style->main.mark_color, + style->main.mark_color, style->main.back_color, + "Mark"); + + do_color_adjuster(&ui, &style->main.highlight_color, + style->main.at_highlight_color, style->main.highlight_color, + "Highlight"); + do_color_adjuster(&ui, &style->main.at_highlight_color, + style->main.at_highlight_color, style->main.highlight_color, + "Text At Highlight"); + + do_color_adjuster(&ui, &style->main.default_color, + style->main.default_color, style->main.back_color, + "Text Default"); + do_color_adjuster(&ui, &style->main.comment_color, + style->main.comment_color, style->main.back_color, + "Comment"); + do_color_adjuster(&ui, &style->main.keyword_color, + style->main.keyword_color, style->main.back_color, + "Keyword"); + do_color_adjuster(&ui, &style->main.str_constant_color, + style->main.str_constant_color, style->main.back_color, + "String Constant"); + do_color_adjuster(&ui, &style->main.char_constant_color, + style->main.char_constant_color, style->main.back_color, + "Character Constant"); + do_color_adjuster(&ui, &style->main.int_constant_color, + style->main.int_constant_color, style->main.back_color, + "Integer Constant"); + do_color_adjuster(&ui, &style->main.float_constant_color, + style->main.float_constant_color, style->main.back_color, + "Float Constant"); + do_color_adjuster(&ui, &style->main.bool_constant_color, + style->main.bool_constant_color, style->main.back_color, + "Boolean Constant"); + do_color_adjuster(&ui, &style->main.preproc_color, + style->main.preproc_color, style->main.back_color, + "Preprocessor"); + do_color_adjuster(&ui, &style->main.include_color, + style->main.include_color, style->main.back_color, + "Include Constant"); + do_color_adjuster(&ui, &style->main.special_character_color, + style->main.special_character_color, style->main.back_color, + "Special Character"); + + do_color_adjuster(&ui, &style->main.highlight_junk_color, + style->main.default_color, style->main.highlight_junk_color, + "Junk Highlight"); + do_color_adjuster(&ui, &style->main.highlight_white_color, + style->main.default_color, style->main.highlight_white_color, + "Whitespace Highlight"); + + do_color_adjuster(&ui, &style->main.paste_color, + style->main.paste_color, style->main.back_color, + "Paste Color"); + + Interactive_Style *bar_style = &style->main.file_info_style; + do_color_adjuster(&ui, &bar_style->bar_color, + bar_style->base_color, bar_style->bar_color, + "Bar"); + do_color_adjuster(&ui, &bar_style->base_color, + bar_style->base_color, bar_style->bar_color, + "Bar Text"); + do_color_adjuster(&ui, &bar_style->pop1_color, + bar_style->pop1_color, bar_style->bar_color, + "Bar Pop 1"); + do_color_adjuster(&ui, &bar_style->pop2_color, + bar_style->pop2_color, bar_style->bar_color, + "Bar Pop 2"); + + *color = ui.hover_color; + + return (result); +} + +internal b32 +theme_shit(System_Functions *system, Exchange *exchange, + View *view, View *active, UI_State *state, UI_Layout *layout, Super_Color *color){ + b32 result = 0; + + if (view != active){ + view->hot_file_view = active; + } + + switch (view->color_mode){ + case CV_Mode_Library: + case CV_Mode_Import_File: + case CV_Mode_Export_File: + case CV_Mode_Import: + case CV_Mode_Export: + case CV_Mode_Import_Wait: + if (theme_library_shit(system, exchange, view, state, layout)){ + result = 1; + } + break; + + case CV_Mode_Adjusting: + if (theme_adjusting_shit(view, state, layout, color)){ + result = 1; + } + break; + } + + return(result); +} + +internal b32 +interactive_shit(System_Functions *system, View *view, UI_State *state, UI_Layout *layout){ + b32 result = 0; + b32 new_dir = 0; + b32 complete = 0; + + Models *models = view->models; + + do_label(state, layout, view->query, 1.f); + + b32 case_sensitive = 0; + + b32 input_stage = state->input_stage; + Key_Summary *keys = state->keys; + + switch (view->interaction){ + case IInt_Sys_File_List: + { + b32 is_new = (view->action == IAct_New); + + if (do_file_list_box(system, state, layout, + &models->hot_directory, 0, !is_new, case_sensitive, + &new_dir, &complete, 0)){ + result = 1; + } + if (new_dir){ + hot_directory_reload(system, &models->hot_directory, &models->working_set); + } + }break; + + case IInt_Live_File_List: + { + if (do_live_file_list_box(system, state, layout, &models->working_set, &view->dest, &complete)){ + result = 1; + } + }break; + + case IInt_Sure_To_Kill: + { + i32 action = -1; + char s_[256]; + String s = make_fixed_width_string(s_); + append(&s, view->dest); + append(&s, " has unsaved changes, kill it?"); + do_label(state, layout, s, 1.f); + + i32 id = 0; + if (do_list_option(++id, state, layout, make_lit_string("(Y)es"))){ + action = 0; + } + + if (do_list_option(++id, state, layout, make_lit_string("(N)o"))){ + action = 1; + } + + if (do_list_option(++id, state, layout, make_lit_string("(S)ave and kill"))){ + action = 2; + } + + if (action == -1 && input_stage){ + i32 key_count = keys->count; + for (i32 i = 0; i < key_count; ++i){ + Key_Event_Data key = keys->keys[i]; + switch (key.character){ + case 'y': case 'Y': action = 0; break; + case 'n': case 'N': action = 1; break; + case 's': case 'S': action = 2; break; + } + if (action == -1 && key.keycode == key_esc) action = 1; + if (action != -1) break; + } + } + + if (action != -1){ + complete = 1; + view->user_action = action; + } + }break; + } + + if (complete){ + view->finished = 1; + interactive_view_complete(view); + result= 1; + } + + return(result); +} + +internal void +menu_shit(View *view, UI_State *state, UI_Layout *layout){ + i32 id = 0; + + do_label(state, layout, literal("Menu"), 2.f); + + if (do_list_option(++id, state, layout, make_lit_string("Theme Options"))){ + view_show_theme(view, view->map); + } + + if (do_list_option(++id, state, layout, make_lit_string("Keyboard Layout Options"))){ + view_show_config(view, view->map); + } +} + +internal void +config_shit(View *view, UI_State *state, UI_Layout *layout){ + i32 id = 0; + Models *models = view->models; + + do_label(state, layout, literal("Config"), 2.f); + + if (do_checkbox_list_option(++id, state, layout, make_lit_string("Left Ctrl + Left Alt = AltGr"), + models->settings.lctrl_lalt_is_altgr)){ + models->settings.lctrl_lalt_is_altgr = !models->settings.lctrl_lalt_is_altgr; + } +} + +struct File_Bar{ + f32 pos_x, pos_y; + f32 text_shift_x, text_shift_y; + i32_Rect rect; + i16 font_id; +}; + +internal void +intbar_draw_string(Render_Target *target, File_Bar *bar, String str, u32 char_color){ + i16 font_id = bar->font_id; + + draw_string(target, font_id, str, + (i32)(bar->pos_x + bar->text_shift_x), + (i32)(bar->pos_y + bar->text_shift_y), + char_color); + bar->pos_x += font_string_width(target, font_id, str); +} + +internal void +do_file_bar(View *view, Editing_File *file, UI_Layout *layout, Render_Target *target){ + File_Bar bar; + Models *models = view->models; + Style_Font *font = &models->global_font; + i32 line_height = view->font_height; + Interactive_Style bar_style = models->style.main.file_info_style; + + u32 back_color = bar_style.bar_color; + u32 base_color = bar_style.base_color; + u32 pop1_color = bar_style.pop1_color; + u32 pop2_color = bar_style.pop2_color; + + bar.rect = layout_rect(layout, line_height + 2); + + if (target){ + bar.font_id = font->font_id; + bar.pos_x = (f32)bar.rect.x0; + bar.pos_y = (f32)bar.rect.y0; + bar.text_shift_y = 2; + bar.text_shift_x = 0; + + draw_rectangle(target, bar.rect, back_color); + intbar_draw_string(target, &bar, file->name.live_name, base_color); + intbar_draw_string(target, &bar, make_lit_string(" -"), base_color); + + if (file->state.is_loading){ + intbar_draw_string(target, &bar, make_lit_string(" loading"), base_color); + } + else{ + char line_number_space[30]; + String line_number = make_string(line_number_space, 0, 30); + append(&line_number, " L#"); + append_int_to_str(view->cursor.line, &line_number); + + intbar_draw_string(target, &bar, line_number, base_color); + + intbar_draw_string(target, &bar, make_lit_string(" -"), base_color); + + if (file->settings.dos_write_mode){ + intbar_draw_string(target, &bar, make_lit_string(" dos"), base_color); + } + else{ + intbar_draw_string(target, &bar, make_lit_string(" nix"), base_color); + } + + if (file->state.still_lexing){ + intbar_draw_string(target, &bar, make_lit_string(" parsing"), pop1_color); + } + + if (!file->settings.unimportant){ + switch (buffer_get_sync(file)){ + case SYNC_BEHIND_OS: + { + persist String out_of_sync = make_lit_string(" !"); + intbar_draw_string(target, &bar, out_of_sync, pop2_color); + }break; + + case SYNC_UNSAVED: + { + persist String out_of_sync = make_lit_string(" *"); + intbar_draw_string(target, &bar, out_of_sync, pop2_color); + }break; + } + } + } + } +} + +internal void +view_reinit_scrolling(View *view){ + Editing_File *file = view->file; + f32 w, h; + f32 cursor_x, cursor_y; + f32 target_x, target_y; + + view->reinit_scrolling = 0; + + target_x = 0; + target_y = 0; + + if (file && file_is_ready(file)){ + cursor_x = view_get_cursor_x(view); + cursor_y = view_get_cursor_y(view); + + w = view_compute_width(view); + h = view_compute_height(view); + + if (cursor_x >= target_x + w){ + target_x = (f32)(cursor_x - w*.5f); + } + + target_y = (f32)FLOOR32(cursor_y - h*.5f); + if (target_y < view->scroll_min_limit) target_y = view->scroll_min_limit; + } + + view->target_x = target_x; + view->target_y = target_y; + view->scroll_x = target_x; + view->scroll_y = target_y; + view->prev_target_x = -1000.f; + view->prev_target_y = -1000.f; +} + +internal i32 +step_file_view(System_Functions *system, Exchange *exchange, View *view, i32_Rect rect, + b32 is_active, Input_Summary *user_input){ + + Models *models = view->models; + i32 result = 0; + Editing_File *file = view->file; + + i32 widget_height = 0; + { + UI_State state = + ui_state_init(&view->widget.state, 0, user_input, + &models->style, models->global_font.font_id, models->font_set, 0, 1); + + UI_Layout layout; + begin_layout(&layout, rect); + + switch (view->widget.type){ + case FWIDG_NONE: + { + if (file && view->showing_ui == VUI_None){ + do_file_bar(view, file, &layout, 0); + } + + draw_file_view_queries(view, &state, &layout); + }break; + + case FWIDG_TIMELINES: + { + i32 scrub_max = view->scrub_max; + i32 undo_count = file->state.undo.undo.edit_count; + i32 redo_count = file->state.undo.redo.edit_count; + i32 total_count = undo_count + redo_count; + + undo_shit(system, view, &state, &layout, total_count, undo_count, scrub_max); + }break; + } + + widget_height = layout.y - rect.y0; + if (ui_finish_frame(&view->widget.state, &state, &layout, rect, 0, 0)){ + result = 1; + } + } + + view->scroll_min_limit = (f32)-widget_height; + if (view->reinit_scrolling){ + view_reinit_scrolling(view); + } + + // TODO(allen): Split this into passive step and step that depends on input + if (view->showing_ui == VUI_None && file && !file->state.is_loading){ + f32 line_height = (f32)view->font_height; + f32 cursor_y = view_get_cursor_y(view); + f32 target_y = view->target_y; + f32 max_y = view_compute_height(view) - line_height*2; + i32 lowest_line = view_compute_lowest_line(view); + f32 max_target_y = view_compute_max_target_y(lowest_line, (i32)line_height, max_y); + f32 delta_y = 3.f*line_height; + f32 extra_top = (f32)widget_height; + f32 taken_top_space = line_height + extra_top; + + if (user_input->mouse.wheel != 0){ + f32 wheel_multiplier = 3.f; + f32 delta_target_y = delta_y*user_input->mouse.wheel*wheel_multiplier; + target_y += delta_target_y; + + if (target_y < -taken_top_space) target_y = -taken_top_space; + if (target_y > max_target_y) target_y = max_target_y; + + f32 old_cursor_y = cursor_y; + if (cursor_y >= target_y + max_y) cursor_y = target_y + max_y; + if (cursor_y < target_y + taken_top_space) cursor_y = target_y + taken_top_space; + + if (cursor_y != old_cursor_y){ + view->cursor = + view_compute_cursor_from_xy(view, + view->preferred_x, + cursor_y); + } + + result = 1; + } + + if (cursor_y > target_y + max_y){ + target_y = cursor_y - max_y + delta_y; + } + if (cursor_y < target_y + taken_top_space){ + target_y = cursor_y - delta_y - taken_top_space; + } + + if (target_y > max_target_y) target_y = max_target_y; + if (target_y < -extra_top) target_y = -extra_top; + view->target_y = target_y; + + f32 cursor_x = view_get_cursor_x(view); + f32 target_x = view->target_x; + f32 max_x = view_compute_width(view); + if (cursor_x < target_x){ + target_x = (f32)Max(0, cursor_x - max_x/2); + } + else if (cursor_x >= target_x + max_x){ + target_x = (f32)(cursor_x - max_x/2); + } + + view->target_x = target_x; + + b32 is_new_target = 0; + if (view->target_x != view->prev_target_x) is_new_target = 1; + if (view->target_y != view->prev_target_y) is_new_target = 1; + + if (view->models->scroll_rule( + view->target_x, view->target_y, + &view->scroll_x, &view->scroll_y, + (view->id) + 1, is_new_target)){ + result = 1; + } + + view->prev_target_x = view->target_x; + view->prev_target_y = view->target_y; + + if (file->state.paste_effect.tick_down > 0){ + --file->state.paste_effect.tick_down; + result = 1; + } + + if (user_input->mouse.press_l && is_active){ + f32 max_y = view_compute_height(view); + f32 rx = (f32)(user_input->mouse.x - rect.x0); + f32 ry = (f32)(user_input->mouse.y - rect.y0); + + if (ry >= extra_top){ + view_set_widget(view, FWIDG_NONE); + if (rx >= 0 && rx < max_x && ry >= 0 && ry < max_y){ + view_cursor_move(view, rx + view->scroll_x, ry + view->scroll_y, 1); + view->mode = {}; + } + } + result = 1; + } + + if (!is_active) view_set_widget(view, FWIDG_NONE); + } + + { + UI_State state = + ui_state_init(&view->ui_state, 0, user_input, + &models->style, models->global_font.font_id, models->font_set, &models->working_set, 1); + + UI_Layout layout; + begin_layout(&layout, rect); + + Super_Color color = {}; + + switch (view->showing_ui){ + case VUI_None: break; + case VUI_Theme: + { + theme_shit(system, exchange, view, 0, &state, &layout, &color); + }break; + case VUI_Interactive: + { + if (interactive_shit(system, view, &state, &layout)){ + result = 1; + } + }break; + case VUI_Menu: + { + menu_shit(view, &state, &layout); + }break; + case VUI_Config: + { + config_shit(view, &state, &layout); + }break; + } + + i32 did_activation = 0; + if (ui_finish_frame(&view->ui_state, &state, &layout, rect, 0, &did_activation)){ + result = 1; + } + if (did_activation){ + if (view->showing_ui == VUI_Theme){ + view->color = color; + result = 1; + } + } + } + + return(result); +} + +internal i32 +draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target){ + Models *models = view->models; + Editing_File *file = view->file; + Style *style = &models->style; + i32 line_height = view->font_height; + + i32 max_x = rect.x1 - rect.x0; + i32 max_y = rect.y1 - rect.y0 + line_height; + + Assert(file && !file->state.is_dummy && buffer_good(&file->state.buffer)); + + b32 tokens_use = 0; + Cpp_Token_Stack token_stack = {}; + if (file){ + tokens_use = file->state.tokens_complete && (file->state.token_stack.count > 0); + token_stack = file->state.token_stack; + } + + Partition *part = &models->mem.part; + + Temp_Memory temp = begin_temp_memory(part); + + partition_align(part, 4); + i32 max = partition_remaining(part) / sizeof(Buffer_Render_Item); + Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, max); + + i16 font_id = models->global_font.font_id; + Render_Font *font = get_font_info(models->font_set, font_id)->font; + float *advance_data = 0; + if (font) advance_data = font->advance_data; + + i32 count; + Full_Cursor render_cursor; + Buffer_Render_Options opts = {}; + + f32 *wraps = view->line_wrap_y; + f32 scroll_x = view->scroll_x; + f32 scroll_y = view->scroll_y; + + { + render_cursor = buffer_get_start_cursor(&file->state.buffer, wraps, scroll_y, + !view->unwrapped_lines, (f32)max_x, advance_data, (f32)line_height); + + view->scroll_i = render_cursor.pos; + + buffer_get_render_data(&file->state.buffer, items, max, &count, + (f32)rect.x0, (f32)rect.y0, + scroll_x, scroll_y, render_cursor, + !view->unwrapped_lines, + (f32)max_x, (f32)max_y, + advance_data, (f32)line_height, + opts); + } + + Assert(count > 0); + + i32 cursor_begin, cursor_end; + u32 cursor_color, at_cursor_color; + if (view->show_temp_highlight){ + cursor_begin = view->temp_highlight.pos; + cursor_end = view->temp_highlight_end_pos; + cursor_color = style->main.highlight_color; + at_cursor_color = style->main.at_highlight_color; + } + else{ + cursor_begin = view->cursor.pos; + cursor_end = cursor_begin + 1; + cursor_color = style->main.cursor_color; + at_cursor_color = style->main.at_cursor_color; + } + + i32 token_i = 0; + u32 main_color = style->main.default_color; + u32 special_color = style->main.special_character_color; + if (tokens_use){ + Cpp_Get_Token_Result result = cpp_get_token(&token_stack, items->index); + main_color = *style_get_color(style, token_stack.tokens[result.token_index]); + token_i = result.token_index + 1; + } + + u32 mark_color = style->main.mark_color; + Buffer_Render_Item *item = items; + i32 prev_ind = -1; + u32 highlight_color = 0; + u32 highlight_this_color = 0; + + for (i32 i = 0; i < count; ++i, ++item){ + i32 ind = item->index; + highlight_this_color = 0; + if (tokens_use && ind != prev_ind){ + Cpp_Token current_token = token_stack.tokens[token_i-1]; + + if (token_i < token_stack.count){ + if (ind >= token_stack.tokens[token_i].start){ + main_color = + *style_get_color(style, token_stack.tokens[token_i]); + current_token = token_stack.tokens[token_i]; + ++token_i; + } + else if (ind >= current_token.start + current_token.size){ + main_color = 0xFFFFFFFF; + } + } + + if (current_token.type == CPP_TOKEN_JUNK && + i >= current_token.start && i < current_token.start + current_token.size){ + highlight_color = style->main.highlight_junk_color; + } + else{ + highlight_color = 0; + } + } + + u32 char_color = main_color; + if (item->flags & BRFlag_Special_Character) char_color = special_color; + + f32_Rect char_rect = f32R(item->x0, item->y0, item->x1, item->y1); + if (view->show_whitespace && highlight_color == 0 && + char_is_whitespace((char)item->glyphid)){ + highlight_this_color = style->main.highlight_white_color; + } + else{ + highlight_this_color = highlight_color; + } + + if (cursor_begin <= ind && ind < cursor_end && (ind != prev_ind || cursor_begin < ind)){ + if (is_active){ + draw_rectangle(target, char_rect, cursor_color); + char_color = at_cursor_color; + } + else{ + if (!view->show_temp_highlight){ + draw_rectangle_outline(target, char_rect, cursor_color); + } + } + } + else if (highlight_this_color){ + draw_rectangle(target, char_rect, highlight_this_color); + } + + u32 fade_color = 0xFFFF00FF; + f32 fade_amount = 0.f; + + if (file->state.paste_effect.tick_down > 0 && + file->state.paste_effect.start <= ind && + ind < file->state.paste_effect.end){ + fade_color = file->state.paste_effect.color; + fade_amount = (f32)(file->state.paste_effect.tick_down) / file->state.paste_effect.tick_max; + } + + char_color = color_blend(char_color, fade_amount, fade_color); + + if (ind == view->mark && prev_ind != ind){ + draw_rectangle_outline(target, char_rect, mark_color); + } + if (item->glyphid != 0){ + font_draw_glyph(target, font_id, (u8)item->glyphid, + item->x0, item->y0, char_color); + } + prev_ind = ind; + } + + end_temp_memory(temp); + + return(0); +} + +internal i32 +draw_file_view(System_Functions *system, Exchange *exchange, + View *view, View *active, i32_Rect rect, b32 is_active, + Render_Target *target, Input_Summary *user_input){ + + Models *models = view->models; + Editing_File *file = view->file; + i32 result = 0; + + i32 widget_height = 0; + { + UI_State state = + ui_state_init(&view->widget.state, target, 0, + &models->style, models->global_font.font_id, models->font_set, 0, 0); + + UI_Layout layout; + begin_layout(&layout, rect); + + switch (view->widget.type){ + case FWIDG_NONE: + { + if (file && view->showing_ui == VUI_None){ + do_file_bar(view, file, &layout, target); + } + + draw_file_view_queries(view, &state, &layout); + }break; + + case FWIDG_TIMELINES: + { + if (file){ + i32 undo_count = file->state.undo.undo.edit_count; + i32 redo_count = file->state.undo.redo.edit_count; + i32 total_count = undo_count + redo_count; + undo_shit(0, view, &state, &layout, total_count, undo_count, 0); + } + else{ + view->widget.type = FWIDG_NONE; + } + }break; + } + + widget_height = layout.y - rect.y0; + ui_finish_frame(&view->widget.state, &state, &layout, rect, 0, 0); + } + view->scroll_min_limit = (f32)-widget_height; + + { + rect.y0 += widget_height; + target->push_clip(target, rect); + + UI_State state = + ui_state_init(&view->ui_state, target, user_input, + &models->style, models->global_font.font_id, models->font_set, &models->working_set, 0); + + UI_Layout layout; + begin_layout(&layout, rect); + + rect.y0 -= widget_height; + + Super_Color color = {}; + + switch (view->showing_ui){ + case VUI_None: + { + if (file && file_is_ready(file)){ + if (view->reinit_scrolling){ + view_reinit_scrolling(view); + } + result = draw_file_loaded(view, rect, is_active, target); + } + }break; + + case VUI_Theme: + { + theme_shit(system, exchange, view, active, &state, &layout, &color); + }break; + + case VUI_Interactive: + { + interactive_shit(system, view, &state, &layout); + }break; + case VUI_Menu: + { + menu_shit(view, &state, &layout); + }break; + case VUI_Config: + { + config_shit(view, &state, &layout); + }break; + } + + ui_finish_frame(&view->ui_state, &state, &layout, rect, 0, 0); + + target->pop_clip(target); + } + + + return (result); +} + +// TODO(allen): Passing this hook and app pointer is a hack. It can go as soon as we start +// initializing files independently of setting them to views. +internal void +kill_file(System_Functions *system, Exchange *exchange, Models *models, Editing_File *file, + Hook_Function *open_hook, Application_Links *app){ + File_Node *node, *used; + + file_close(system, &models->mem.general, file); + working_set_free_file(&models->working_set, file); + + used = &models->working_set.used_sentinel; + node = used->next; + + for (View_Iter iter = file_view_iter_init(&models->layout, file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + if (node != used){ + iter.view->file = 0; + view_set_file(iter.view, (Editing_File*)node, models, system, open_hook, app, 0); + node = node->next; + } + else{ + iter.view->file = 0; + view_set_file(iter.view, 0, models, system, open_hook, app, 0); + } + } +} + +inline void +free_file_view(View *view){ + if (view->line_wrap_y) + general_memory_free(&view->models->mem.general, view->line_wrap_y); +} + +struct Search_Range{ + Buffer_Type *buffer; + i32 start, size; +}; + +struct Search_Set{ + Search_Range *ranges; + i32 count, max; +}; + +struct Search_Iter{ + String word; + i32 pos; + i32 i; +}; + +struct Search_Match{ + Buffer_Type *buffer; + i32 start, end; + b32 found_match; +}; + +internal void +search_iter_init(General_Memory *general, Search_Iter *iter, i32 size){ + i32 str_max; + + if (iter->word.str == 0){ + str_max = size*2; + iter->word.str = (char*)general_memory_allocate(general, str_max, 0); + iter->word.memory_size = str_max; + } + else if (iter->word.memory_size < size){ + str_max = size*2; + iter->word.str = (char*)general_memory_reallocate_nocopy(general, iter->word.str, str_max, 0); + iter->word.memory_size = str_max; + } + + iter->i = 0; + iter->pos = 0; +} + +internal void +search_set_init(General_Memory *general, Search_Set *set, i32 set_count){ + i32 max; + + if (set->ranges == 0){ + max = set_count*2; + set->ranges = (Search_Range*)general_memory_allocate(general, sizeof(Search_Range)*max, 0); + set->max = max; + } + else if (set->max < set_count){ + max = set_count*2; + set->ranges = (Search_Range*)general_memory_reallocate_nocopy( + general, set->ranges, sizeof(Search_Range)*max, 0); + set->max = max; + } + + set->count = set_count; +} + +internal void +search_hits_table_alloc(General_Memory *general, Table *hits, i32 table_size){ + i32 hash_size, mem_size; + + hash_size = table_size * sizeof(u32); + hash_size = (hash_size + 7) & ~7; + mem_size = hash_size + table_size * sizeof(Offset_String); + + hits->hash_array = (u32*)general_memory_allocate(general, mem_size, 0); + hits->data_array = (u8*)hits->hash_array + hash_size; + hits->max = table_size; + + hits->item_size = sizeof(Offset_String); +} + +internal void +search_hits_init(General_Memory *general, Table *hits, String_Space *str, i32 table_size, i32 str_size){ + i32 hash_size, mem_size; + + if (hits->hash_array == 0){ + search_hits_table_alloc(general, hits, table_size); + } + else if (hits->max < table_size){ + hash_size = table_size * sizeof(u32); + hash_size = (hash_size + 7) & ~7; + mem_size = hash_size + table_size * sizeof(Offset_String); + + hits->hash_array = (u32*)general_memory_reallocate_nocopy( + general, hits->hash_array, mem_size, 0); + hits->data_array = (u8*)hits->hash_array + hash_size; + hits->max = table_size; + + hits->item_size = sizeof(Offset_String); + } + + if (str->space == 0){ + str->space = (char*)general_memory_allocate(general, str_size, 0); + str->max = str_size; + } + else if (str->max < str_size){ + str->space = (char*)general_memory_reallocate_nocopy(general, str->space, str_size, 0); + str->max = str_size; + } + + str->pos = str->new_pos = 0; + table_clear(hits); +} + +internal b32 +search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, i32 len){ + b32 result; + i32 new_size; + Offset_String ostring; + Table new_hits; + + Assert(len != 0); + + ostring = strspace_append(space, str, len); + if (ostring.size == 0){ + new_size = Max(space->max*2, space->max + len); + space->space = (char*)general_memory_reallocate(general, space->space, space->new_pos, new_size, 0); + ostring = strspace_append(space, str, len); + } + + Assert(ostring.size != 0); + + if (table_at_capacity(hits)){ + search_hits_table_alloc(general, &new_hits, hits->max*2); + table_clear(&new_hits); + table_rehash(hits, &new_hits, space->space, tbl_offset_string_hash, tbl_offset_string_compare); + general_memory_free(general, hits->hash_array); + *hits = new_hits; + } + + if (!table_add(hits, &ostring, space->space, tbl_offset_string_hash, tbl_offset_string_compare)){ + result = 1; + strspace_keep_prev(space); + } + else{ + result = 0; + strspace_discard_prev(space); + } + + return(result); +} + +internal Search_Match +search_next_match(Partition *part, Search_Set *set, Search_Iter *iter_){ + Search_Match result = {}; + Search_Iter iter = *iter_; + Search_Range *range; + Temp_Memory temp; + char *spare; + i32 start_pos, end_pos, count; + + temp = begin_temp_memory(part); + spare = push_array(part, char, iter.word.size); + + count = set->count; + for (; iter.i < count;){ + range = set->ranges + iter.i; + + end_pos = range->start + range->size; + + if (iter.pos + iter.word.size < end_pos){ + start_pos = Max(iter.pos, range->start); + result.start = buffer_find_string(range->buffer, start_pos, end_pos, iter.word.str, iter.word.size, spare); + + if (result.start < end_pos){ + iter.pos = result.start + 1; + if (result.start == 0 || !char_is_alpha_numeric(buffer_get_char(range->buffer, result.start - 1))){ + result.end = buffer_seek_word_right_assume_on_word(range->buffer, result.start); + if (result.end < end_pos){ + result.found_match = 1; + result.buffer = range->buffer; + iter.pos = result.end; + break; + } + } + } + else{ + ++iter.i, iter.pos = 0; + } + } + else{ + ++iter.i, iter.pos = 0; + } + } + end_temp_memory(temp); + + *iter_ = iter; + + return(result); +} + +inline void +view_change_size(System_Functions *system, General_Memory *general, View *view){ + if (view->file){ + view_measure_wraps(system, general, view); + view->cursor = view_compute_cursor_from_pos(view, view->cursor.pos); + } +} + +struct Live_Views{ + View *views; + View free_sentinel; + i32 count, max; +}; + +internal View_And_ID +live_set_alloc_view(Live_Views *live_set, Panel *panel, Models *models){ + View_And_ID result = {}; + + Assert(live_set->count < live_set->max); + ++live_set->count; + + result.view = live_set->free_sentinel.next; + result.id = (i32)(result.view - live_set->views); + + dll_remove(result.view); + memset(result.view, 0, sizeof(View)); + result.view->id = result.id; + + result.view->in_use = 1; + panel->view = result.view; + result.view->panel = panel; + + result.view->models = models; + result.view->scrub_max = 1; + + // TODO(allen): Make "interactive" mode customizable just like the query bars! + result.view->query = make_fixed_width_string(result.view->query_); + result.view->dest = make_fixed_width_string(result.view->dest_); + + init_query_set(&result.view->query_set); + + return(result); +} + +inline void +live_set_free_view(System_Functions *system, Exchange *exchange, Live_Views *live_set, View *view){ + Assert(live_set->count > 0); + --live_set->count; + free_file_view(view); + dll_insert(&live_set->free_sentinel, view); + view->in_use = 0; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_font_set.cpp b/test_data/lots_of_files/4ed_font_set.cpp new file mode 100644 index 0000000..e041092 --- /dev/null +++ b/test_data/lots_of_files/4ed_font_set.cpp @@ -0,0 +1,230 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 18.12.2015 + * + * Font set for 4coder + * + */ + +// TOP + +inline u32 +font_hash(String name){ + u32 x = 5381; + char *p = name.str; + for (i32 i = 0; i < name.size; ++i, ++p){ + x = ((x << 5) + x) ^ (*p); + } + return(x); +} + +inline void +font__insert(Font_Slot *pos, Font_Slot *slot){ + Font_Slot *nex; + nex = pos->next; + + slot->next = nex; + slot->prev = pos; + nex->prev = slot; + pos->next = slot; +} + +inline void +font__remove(Font_Slot *slot){ + Font_Slot *n, *p; + n = slot->next; + p = slot->prev; + + p->next = n; + n->prev = p; +} + +internal void +font_set_init(Font_Set *set, Partition *partition, i32 max, i16 live_max){ + partition_align(partition, 8); + set->info = push_array(partition, Font_Info, max); + partition_align(partition, 8); + set->entries = push_array(partition, Font_Table_Entry, max); + set->count = 0; + set->max = max; + + partition_align(partition, 8); + set->font_block = push_block(partition, live_max*(sizeof(Render_Font) + sizeof(Font_Slot))); + + set->free_slots = {}; + set->used_slots = {}; + + dll_init_sentinel(&set->free_slots); + dll_init_sentinel(&set->used_slots); + + char *ptr = (char*)set->font_block; + for (i32 i = 0; i < live_max; ++i){ + dll_insert(&set->free_slots, (Font_Slot*)ptr); + ptr += sizeof(Font_Slot) + sizeof(Render_Font); + } + + set->font_used_flags = push_array(partition, b8, max); + set->live_max = live_max; +} + +internal b32 +font_set_can_add(Font_Set *set){ + b32 result = 0; + if (set->count*8 < set->max*7) result = 1; + return(result); +} + +internal void +font_set_add_hash(Font_Set *set, String name, i16 font_id){ + Font_Table_Entry entry; + entry.hash = font_hash(name); + entry.name = name; + entry.font_id = font_id; + + u32 i, j; + i = entry.hash % set->max; + j = i - 1; + if (i <= 1) j += set->max; + + for (; i != j; ++i){ + if (i == set->max) i = 0; + if (set->entries[i].font_id == 0){ + set->entries[i] = entry; + break; + } + } + + Assert(i != j); +} + +inline b32 +font_set_can_load(Font_Set *set){ + b32 result = (set->free_slots.next != &set->free_slots); + return(result); +} + +internal void +font_set_load(Partition *partition, Font_Set *set, i16 font_id){ + Font_Info *info = get_font_info(set, font_id); + Font_Slot *slot = set->free_slots.next; + Assert(slot != &set->free_slots); + font__remove(slot); + font__insert(&set->used_slots, slot); + + Render_Font *font = (Render_Font*)(slot + 1); + set->font_load(font, info->filename.str, info->pt_size, 4); + info->font = font; + slot->font_id = font_id; +} + +internal void +font_set_evict_lru(Font_Set *set){ + Font_Slot *slot = set->used_slots.prev; + Assert(slot != &set->used_slots); + + i16 font_id = slot->font_id; + Font_Info *info = get_font_info(set, font_id); + Assert(((Font_Slot*)info->font) - 1 == slot); + + set->release_font(info->font); + + info->font = 0; + slot->font_id = 0; + font__remove(slot); + font__insert(&set->free_slots, slot); +} + +internal void +font_set_use(Partition *partition, Font_Set *set, i16 font_id){ + b8 already_used; + already_used = set->font_used_flags[font_id-1]; + + if (!already_used){ + if (set->used_this_frame < set->live_max){ + ++set->used_this_frame; + set->font_used_flags[font_id-1] = 1; + already_used = 1; + } + } + + if (already_used){ + // TODO(allen): optimize if you don't mind!!!! + Font_Info *info = get_font_info(set, font_id); + Font_Slot *slot; + if (info->font == 0){ + if (!font_set_can_load(set)){ + font_set_evict_lru(set); + } + font_set_load(partition, set, font_id); + } + slot = ((Font_Slot*)info->font) - 1; + + font__remove(slot); + font__insert(&set->used_slots, slot); + } +} + +internal b32 +font_set_add(Partition *partition, Font_Set *set, + String filename, String name, i32 pt_size){ + b32 result = 0; + if (font_set_can_add(set)){ + i16 font_id = (i16)(++set->count); + Font_Info *info = get_font_info(set, font_id); + info->filename = filename; + info->name = name; + info->pt_size = pt_size; + set->font_info_load(partition, filename.str, pt_size, &info->height, &info->advance); + font_set_add_hash(set, name, font_id); + + if (font_set_can_load(set)){ + font_set_load(partition, set, font_id); + } + + result = 1; + } + return(result); +} + +internal b32 +font_set_find_pos(Font_Set *set, String name, u32 *position){ + b32 result; + u32 hash, i, j; + hash = font_hash(name); + i = hash % set->max; + j = i - 1; + if (j <= 1) j += set->max; + + result = 0; + Font_Table_Entry *entry; + for (; i != j; ++i){ + if (i == set->max) i = 0; + entry = set->entries + i; + if (entry->hash == hash){ + if (match(name, entry->name)){ + result = 1; + *position = i; + break; + } + } + } + + return(result); +} + +internal b32 +font_set_extract(Font_Set *set, String name, i16 *font_id){ + b32 result; + u32 position; + + result = font_set_find_pos(set, name, &position); + if (result){ + *font_id = set->entries[position].font_id; + } + + return(result); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_gui.cpp b/test_data/lots_of_files/4ed_gui.cpp new file mode 100644 index 0000000..59b4baf --- /dev/null +++ b/test_data/lots_of_files/4ed_gui.cpp @@ -0,0 +1,2227 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 20.02.2016 + * + * GUI system for 4coder + * + */ + +// TOP + +struct Query_Slot{ + Query_Slot *next; + Query_Bar *query_bar; +}; + +struct Query_Set{ + Query_Slot slots[8]; + Query_Slot *free_slot; + Query_Slot *used_slot; +}; + +internal void +init_query_set(Query_Set *set){ + Query_Slot *slot = set->slots; + int i; + + set->free_slot = slot; + set->used_slot = 0; + for (i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){ + slot->next = slot + 1; + } +} + +internal Query_Slot* +alloc_query_slot(Query_Set *set){ + Query_Slot *slot = set->free_slot; + if (slot != 0){ + set->free_slot = slot->next; + slot->next = set->used_slot; + set->used_slot = slot; + } + return(slot); +} + +internal void +free_query_slot(Query_Set *set, Query_Bar *match_bar){ + Query_Slot *slot = 0, *prev = 0; + + for (slot = set->used_slot; slot != 0; slot = slot->next){ + if (slot->query_bar == match_bar) break; + prev = slot; + } + + if (slot){ + if (prev){ + prev->next = slot->next; + } + else{ + set->used_slot = slot->next; + } + slot->next = set->free_slot; + set->free_slot = slot; + } +} + +struct Single_Line_Input_Step{ + b8 hit_newline; + b8 hit_ctrl_newline; + b8 hit_a_character; + b8 hit_backspace; + b8 hit_esc; + b8 made_a_change; + b8 did_command; + b8 no_file_match; +}; + +enum Single_Line_Input_Type{ + SINGLE_LINE_STRING, + SINGLE_LINE_FILE +}; + +struct Single_Line_Mode{ + Single_Line_Input_Type type; + String *string; + Hot_Directory *hot_directory; + b32 fast_folder_select; + b32 try_to_match; + b32 case_sensitive; +}; + +internal Single_Line_Input_Step +app_single_line_input_core(System_Functions *system, Working_Set *working_set, + Key_Event_Data key, Single_Line_Mode mode){ + Single_Line_Input_Step result = {}; + + if (key.keycode == key_back){ + result.hit_backspace = 1; + if (mode.string->size > 0){ + result.made_a_change = 1; + --mode.string->size; + switch (mode.type){ + case SINGLE_LINE_STRING: + mode.string->str[mode.string->size] = 0; break; + + case SINGLE_LINE_FILE: + { + char end_character = mode.string->str[mode.string->size]; + if (char_is_slash(end_character)){ + mode.string->size = reverse_seek_slash(*mode.string) + 1; + mode.string->str[mode.string->size] = 0; + hot_directory_set(system, mode.hot_directory, *mode.string, working_set); + } + else{ + mode.string->str[mode.string->size] = 0; + } + }break; + } + } + } + + else if (key.character == '\n' || key.character == '\t'){ + result.made_a_change = 1; + if (key.modifiers[MDFR_CONTROL_INDEX] || + key.modifiers[MDFR_ALT_INDEX]){ + result.hit_ctrl_newline = 1; + } + else{ + result.hit_newline = 1; + if (mode.fast_folder_select){ + Hot_Directory_Match match; + char front_name_space[256]; + String front_name = make_fixed_width_string(front_name_space); + get_front_of_directory(&front_name, *mode.string); + + match = + hot_directory_first_match(mode.hot_directory, front_name, 1, 1, mode.case_sensitive); + + if (mode.try_to_match && !match.filename.str){ + match = hot_directory_first_match(mode.hot_directory, front_name, 1, 0, mode.case_sensitive); + } + if (match.filename.str){ + if (match.is_folder){ + set_last_folder(mode.string, match.filename, mode.hot_directory->slash); + hot_directory_set(system, mode.hot_directory, *mode.string, working_set); + result.hit_newline = 0; + } + else{ + if (mode.try_to_match){ + mode.string->size = reverse_seek_slash(*mode.string) + 1; + append(mode.string, match.filename); + } + } + } + else{ + if (mode.try_to_match){ + result.no_file_match = 1; + } + } + } + } + } + + else if (key.keycode == key_esc){ + result.hit_esc = 1; + result.made_a_change = 1; + } + + else if (key.character){ + result.hit_a_character = 1; + if (!key.modifiers[MDFR_CONTROL_INDEX] && + !key.modifiers[MDFR_ALT_INDEX]){ + if (mode.string->size+1 < mode.string->memory_size){ + u8 new_character = (u8)key.character; + mode.string->str[mode.string->size] = new_character; + mode.string->size++; + mode.string->str[mode.string->size] = 0; + if (mode.type == SINGLE_LINE_FILE && char_is_slash(new_character)){ + hot_directory_set(system, mode.hot_directory, *mode.string, working_set); + } + result.made_a_change = 1; + } + } + else{ + result.did_command = 1; + result.made_a_change = 1; + } + } + + return result; +} + +inline Single_Line_Input_Step +app_single_line_input_step(System_Functions *system, Key_Event_Data key, String *string){ + Single_Line_Mode mode = {}; + mode.type = SINGLE_LINE_STRING; + mode.string = string; + return app_single_line_input_core(system, 0, key, mode); +} + +inline Single_Line_Input_Step +app_single_file_input_step(System_Functions *system, + Working_Set *working_set, Key_Event_Data key, + String *string, Hot_Directory *hot_directory, + b32 fast_folder_select, b32 try_to_match, b32 case_sensitive){ + Single_Line_Mode mode = {}; + mode.type = SINGLE_LINE_FILE; + mode.string = string; + mode.hot_directory = hot_directory; + mode.fast_folder_select = fast_folder_select; + mode.try_to_match = try_to_match; + mode.case_sensitive = case_sensitive; + return app_single_line_input_core(system, working_set, key, mode); +} + +inline Single_Line_Input_Step +app_single_number_input_step(System_Functions *system, Key_Event_Data key, String *string){ + Single_Line_Input_Step result = {}; + Single_Line_Mode mode = {}; + mode.type = SINGLE_LINE_STRING; + mode.string = string; + + char c = (char)key.character; + if (c == 0 || c == '\n' || char_is_numeric(c)) + result = app_single_line_input_core(system, 0, key, mode); + return result; +} + +struct Widget_ID{ + i32 id; + i32 sub_id0; + i32 sub_id1; + i32 sub_id2; +}; + +inline b32 +widget_match(Widget_ID s1, Widget_ID s2){ + return (s1.id == s2.id && s1.sub_id0 == s2.sub_id0 && + s1.sub_id1 == s2.sub_id1 && s1.sub_id2 == s2.sub_id2); +} + +struct UI_State{ + Render_Target *target; + Style *style; + Font_Set *font_set; + Mouse_State *mouse; + Key_Summary *keys; + Working_Set *working_set; + i16 font_id; + + Widget_ID selected, hover, hot; + b32 activate_me; + b32 redraw; + b32 input_stage; + i32 sub_id1_change; + + f32 height, view_y; +}; + +inline Widget_ID +make_id(UI_State *state, i32 id){ + Widget_ID r = state->selected; + r.id = id; + return r; +} + +inline Widget_ID +make_sub0(UI_State *state, i32 id){ + Widget_ID r = state->selected; + r.sub_id0 = id; + return r; +} + +inline Widget_ID +make_sub1(UI_State *state, i32 id){ + Widget_ID r = state->selected; + r.sub_id1 = id; + return r; +} + +inline Widget_ID +make_sub2(UI_State *state, i32 id){ + Widget_ID r = state->selected; + r.sub_id2 = id; + return r; +} + +inline b32 +is_selected(UI_State *state, Widget_ID id){ + return widget_match(state->selected, id); +} + +inline b32 +is_hot(UI_State *state, Widget_ID id){ + return widget_match(state->hot, id); +} + +inline b32 +is_hover(UI_State *state, Widget_ID id){ + return widget_match(state->hover, id); +} + +struct UI_Layout{ + i32 row_count; + i32 row_item_width; + i32 row_max_item_height; + + i32_Rect rect; + i32 x, y; +}; + +struct UI_Layout_Restore{ + UI_Layout layout; + UI_Layout *dest; +}; + +inline void +begin_layout(UI_Layout *layout, i32_Rect rect){ + layout->rect = rect; + layout->x = rect.x0; + layout->y = rect.y0; + layout->row_count = 0; + layout->row_max_item_height = 0; +} + +inline void +begin_row(UI_Layout *layout, i32 count){ + layout->row_count = count; + layout->row_item_width = (layout->rect.x1 - layout->x) / count; +} + +inline i32_Rect +layout_rect(UI_Layout *layout, i32 height){ + i32_Rect rect; + rect.x0 = layout->x; + rect.y0 = layout->y; + rect.x1 = rect.x0; + rect.y1 = rect.y0 + height; + if (layout->row_count > 0){ + --layout->row_count; + rect.x1 = rect.x0 + layout->row_item_width; + layout->x += layout->row_item_width; + layout->row_max_item_height = Max(height, layout->row_max_item_height); + } + if (layout->row_count == 0){ + rect.x1 = layout->rect.x1; + layout->row_max_item_height = Max(height, layout->row_max_item_height); + layout->y += layout->row_max_item_height; + layout->x = layout->rect.x0; + layout->row_max_item_height = 0; + } + return rect; +} + +inline UI_Layout_Restore +begin_sub_layout(UI_Layout *layout, i32_Rect area){ + UI_Layout_Restore restore; + restore.layout = *layout; + restore.dest = layout; + begin_layout(layout, area); + return restore; +} + +inline void +end_sub_layout(UI_Layout_Restore restore){ + *restore.dest = restore.layout; +} + +struct UI_Style{ + u32 dark, dim, bright; + u32 base, pop1, pop2; +}; + +internal UI_Style +get_ui_style(Style *style){ + UI_Style ui_style; + ui_style.dark = style->main.back_color; + ui_style.dim = style->main.margin_color; + ui_style.bright = style->main.margin_active_color; + ui_style.base = style->main.default_color; + ui_style.pop1 = style->main.file_info_style.pop1_color; + ui_style.pop2 = style->main.file_info_style.pop2_color; + return ui_style; +} + +internal UI_Style +get_ui_style_upper(Style *style){ + UI_Style ui_style; + ui_style.dark = style->main.margin_color; + ui_style.dim = style->main.margin_hover_color; + ui_style.bright = style->main.margin_active_color; + ui_style.base = style->main.default_color; + ui_style.pop1 = style->main.file_info_style.pop1_color; + ui_style.pop2 = style->main.file_info_style.pop2_color; + return ui_style; +} + +inline void +get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style){ + bool32 hover = is_hover(state, wid); + bool32 hot = is_hot(state, wid); + i32 level = hot + hover; + switch (level){ + case 2: + *back = style.bright; + *fore = style.dark; + break; + case 1: + *back = style.dim; + *fore = style.bright; + break; + case 0: + *back = style.dark; + *fore = style.bright; + break; + } +} + +inline void +get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){ + bool32 hover = is_hover(state, wid); + bool32 hot = is_hot(state, wid); + i32 level = hot + hover; + switch (level){ + case 2: + *pop = style.pop1; + break; + case 1: + *pop = style.pop1; + break; + case 0: + *pop = style.pop1; + break; + } +} + +internal UI_State +ui_state_init(UI_State *state_in, Render_Target *target, Input_Summary *user_input, + Style *style, i16 font_id, Font_Set *font_set, Working_Set *working_set, + b32 input_stage){ + UI_State state = {}; + state.target = target; + state.style = style; + state.font_set = font_set; + state.font_id = font_id; + state.working_set = working_set; + if (user_input){ + state.mouse = &user_input->mouse; + state.keys = &user_input->keys; + } + state.selected = state_in->selected; + state.hot = state_in->hot; + if (input_stage) state.hover = {}; + else state.hover = state_in->hover; + state.redraw = 0; + state.activate_me = 0; + state.input_stage = input_stage; + state.height = state_in->height; + state.view_y = state_in->view_y; + return state; +} + +inline b32 +ui_state_match(UI_State a, UI_State b){ + return (widget_match(a.selected, b.selected) && + widget_match(a.hot, b.hot) && + widget_match(a.hover, b.hover)); +} + +internal b32 +ui_finish_frame(UI_State *persist_state, UI_State *state, UI_Layout *layout, i32_Rect rect, + b32 do_wheel, b32 *did_activation){ + b32 result = 0; + f32 h = layout->y + persist_state->view_y - rect.y0; + f32 max_y = h - (rect.y1 - rect.y0); + + persist_state->height = h; + persist_state->view_y = state->view_y; + + if (state->input_stage){ + Mouse_State *mouse = state->mouse; + Font_Set *font_set = state->font_set; + + if (mouse->wheel != 0 && do_wheel){ + i32 height = get_font_info(font_set, state->font_id)->height; + persist_state->view_y += mouse->wheel*height; + result = 1; + } + if (mouse->release_l && widget_match(state->hot, state->hover)){ + if (did_activation) *did_activation = 1; + if (state->activate_me){ + state->selected = state->hot; + } + } + if (!mouse->l && !mouse->r){ + state->hot = {}; + } + + if (!ui_state_match(*persist_state, *state) || state->redraw){ + result = 1; + } + + *persist_state = *state; + } + + if (persist_state->view_y >= max_y) persist_state->view_y = max_y; + if (persist_state->view_y < 0) persist_state->view_y = 0; + + return result; +} + +internal b32 +ui_do_button_input(UI_State *state, i32_Rect rect, Widget_ID id, bool32 activate, bool32 *right = 0){ + b32 result = 0; + Mouse_State *mouse = state->mouse; + b32 hover = hit_check(mouse->x, mouse->y, rect); + if (hover){ + state->hover = id; + if (activate) state->activate_me = 1; + if (mouse->press_l || (mouse->press_r && right)) state->hot = id; + if (mouse->l && mouse->r) state->hot = {}; + } + bool32 is_match = is_hot(state, id); + if (mouse->release_l && is_match){ + if (hover) result = 1; + state->redraw = 1; + } + if (right && mouse->release_r && is_match){ + if (hover) *right = 1; + state->redraw = 1; + } + return result; +} + +internal bool32 +ui_do_subdivided_button_input(UI_State *state, i32_Rect rect, i32 parts, Widget_ID id, bool32 activate, i32 *indx_out, bool32 *right = 0){ + bool32 result = 0; + real32 x0, x1; + i32_Rect sub_rect; + Widget_ID sub_widg = id; + real32 sub_width = (rect.x1 - rect.x0) / (real32)parts; + sub_rect.y0 = rect.y0; + sub_rect.y1 = rect.y1; + x1 = (real32)rect.x0; + + for (i32 i = 0; i < parts; ++i){ + x0 = x1; + x1 = x1 + sub_width; + sub_rect.x0 = TRUNC32(x0); + sub_rect.x1 = TRUNC32(x1); + sub_widg.sub_id2 = i; + if (ui_do_button_input(state, sub_rect, sub_widg, activate, right)){ + *indx_out = i; + break; + } + } + + return result; +} + +internal real32 +ui_do_vscroll_input(UI_State *state, i32_Rect top, i32_Rect bottom, i32_Rect slider, + Widget_ID id, real32 val, real32 step_amount, + real32 smin, real32 smax, real32 vmin, real32 vmax){ + Mouse_State *mouse = state->mouse; + i32 mx = mouse->x; + i32 my = mouse->y; + if (hit_check(mx, my, top)){ + state->hover = id; + state->hover.sub_id2 = 1; + } + if (hit_check(mx, my, bottom)){ + state->hover = id; + state->hover.sub_id2 = 2; + } + if (hit_check(mx, my, slider)){ + state->hover = id; + state->hover.sub_id2 = 3; + } + if (mouse->press_l) state->hot = state->hover; + if (id.id == state->hot.id){ + if (mouse->release_l){ + Widget_ID wid1, wid2; + wid1 = wid2 = id; + wid1.sub_id2 = 1; + wid2.sub_id2 = 2; + if (state->hot.sub_id2 == 1 && is_hover(state, wid1)) val -= step_amount; + if (state->hot.sub_id2 == 2 && is_hover(state, wid2)) val += step_amount; + state->redraw = 1; + } + if (state->hot.sub_id2 == 3){ + f32 S, L; + S = (f32)mouse->y - (slider.y1 - slider.y0) / 2; + if (S < smin) S = smin; + if (S > smax) S = smax; + L = unlerp(smin, S, smax); + val = lerp(vmin, L, vmax); + state->redraw = 1; + } + } + return val; +} + +internal b32 +ui_do_text_field_input(UI_State *state, String *str){ + b32 result = 0; + Key_Summary *keys = state->keys; + for (i32 key_i = 0; key_i < keys->count; ++key_i){ + Key_Event_Data key = get_single_key(keys, key_i); + char c = (char)key.character; + if (char_is_basic(c) && str->size < str->memory_size-1){ + str->str[str->size++] = c; + str->str[str->size] = 0; + } + else if (c == '\n'){ + result = 1; + } + else if (key.keycode == key_back && str->size > 0){ + str->str[--str->size] = 0; + } + } + return result; +} + +internal b32 +ui_do_file_field_input(System_Functions *system, UI_State *state, + Hot_Directory *hot_dir, b32 try_to_match, b32 case_sensitive){ + Key_Event_Data key; + Single_Line_Input_Step step; + String *str = &hot_dir->string; + Key_Summary *keys = state->keys; + i32 key_i; + b32 result = 0; + + terminate_with_null(str); + + for (key_i = 0; key_i < keys->count; ++key_i){ + key = get_single_key(keys, key_i); + step = + app_single_file_input_step(system, state->working_set, key, str, + hot_dir, 1, try_to_match, case_sensitive); + if ((step.hit_newline || step.hit_ctrl_newline) && !step.no_file_match) result = 1; + } + return result; +} + +internal b32 +ui_do_line_field_input(System_Functions *system, + UI_State *state, String *string){ + b32 result = 0; + Key_Summary *keys = state->keys; + for (i32 key_i = 0; key_i < keys->count; ++key_i){ + Key_Event_Data key = get_single_key(keys, key_i); + terminate_with_null(string); + Single_Line_Input_Step step = + app_single_line_input_step(system, key, string); + if (step.hit_newline || step.hit_ctrl_newline) result = 1; + } + return result; +} + +internal b32 +ui_do_slider_input(UI_State *state, i32_Rect rect, Widget_ID wid, + real32 min, real32 max, real32 *v){ + b32 result = 0; + ui_do_button_input(state, rect, wid, 0); + Mouse_State *mouse = state->mouse; + if (is_hot(state, wid)){ + result = 1; + *v = unlerp(min, (f32)mouse->x, max); + state->redraw = 1; + } + return result; +} + +internal bool32 +do_text_field(Widget_ID wid, UI_State *state, UI_Layout *layout, String prompt, String dest){ + b32 result = 0; + i32 character_h = get_font_info(state->font_set, state->font_id)->height; + + i32_Rect rect = layout_rect(layout, character_h); + + if (state->input_stage){ + ui_do_button_input(state, rect, wid, 1); + if (is_selected(state, wid)){ + if (ui_do_text_field_input(state, &dest)){ + result = 1; + } + } + } + else{ + Render_Target *target = state->target; + UI_Style ui_style = get_ui_style_upper(state->style); + u32 back, fore, prompt_pop; + get_colors(state, &back, &fore, wid, ui_style); + get_pop_color(state, &prompt_pop, wid, ui_style); + + draw_rectangle(target, rect, back); + + i32 x = draw_string(target, state->font_id, prompt, rect.x0, rect.y0 + 1, prompt_pop); + draw_string(target, state->font_id, dest, x, rect.y0 + 1, ui_style.base); + } + + return result; +} + +internal b32 +do_button(i32 id, UI_State *state, UI_Layout *layout, char *text, i32 height_mult, + b32 is_toggle = 0, b32 on = 0){ + b32 result = 0; + i16 font_id = state->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + + i32_Rect btn_rect = layout_rect(layout, character_h * height_mult); + if (height_mult > 1) btn_rect = get_inner_rect(btn_rect, 2); + else{ + btn_rect.x0 += 2; + btn_rect.x1 -= 2; + } + + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + if (ui_do_button_input(state, btn_rect, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + UI_Style ui_style = get_ui_style(state->style); + u32 back, fore, outline; + outline = ui_style.bright; + get_colors(state, &back, &fore, wid, ui_style); + + draw_rectangle(target, btn_rect, back); + draw_rectangle_outline(target, btn_rect, outline); + real32 text_width = font_string_width(target, font_id, text); + i32 box_width = btn_rect.x1 - btn_rect.x0; + i32 box_height = btn_rect.y1 - btn_rect.y0; + i32 x_pos = TRUNC32(btn_rect.x0 + (box_width - text_width)*.5f); + draw_string(target, font_id, text, x_pos, btn_rect.y0 + (box_height - character_h) / 2, fore); + + if (is_toggle){ + i32_Rect on_box = get_inner_rect(btn_rect, character_h/2); + on_box.x1 = on_box.x0 + (on_box.y1 - on_box.y0); + + if (on) draw_rectangle(target, on_box, fore); + else draw_rectangle(target, on_box, back); + draw_rectangle_outline(target, on_box, fore); + } + } + + return result; +} + +internal b32 +do_undo_slider(Widget_ID wid, UI_State *state, UI_Layout *layout, i32 max, i32 v, Undo_Data *undo, i32 *out){ + b32 result = 0; + i16 font_id = state->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + + i32_Rect containing_rect = layout_rect(layout, character_h); + + i32_Rect click_rect; + click_rect.x0 = containing_rect.x0 + character_h - 1; + click_rect.x1 = containing_rect.x1 - character_h + 1; + click_rect.y0 = containing_rect.y0 + 2; + click_rect.y1 = containing_rect.y1 - 2; + + if (state->input_stage){ + real32 l; + if (ui_do_slider_input(state, click_rect, wid, (real32)click_rect.x0, (real32)click_rect.x1, &l)){ + real32 v_new = lerp(0.f, l, (real32)max); + v = ROUND32(v_new); + result = 1; + if (out) *out = v; + } + } + else{ + Render_Target *target = state->target; + if (max > 0){ + UI_Style ui_style = get_ui_style_upper(state->style); + + real32 L = unlerp(0.f, (real32)v, (real32)max); + i32 x = FLOOR32(lerp((real32)click_rect.x0, L, (real32)click_rect.x1)); + + i32 bar_top = ((click_rect.y0 + click_rect.y1) >> 1) - 1; + i32 bar_bottom = bar_top + 2; + + bool32 show_bar = 1; + real32 tick_step = (click_rect.x1 - click_rect.x0) / (real32)max; + bool32 show_ticks = 1; + if (tick_step <= 5.f) show_ticks = 0; + + if (undo == 0){ + if (show_bar){ + i32_Rect slider_rect; + slider_rect.x0 = click_rect.x0; + slider_rect.x1 = x; + slider_rect.y0 = bar_top; + slider_rect.y1 = bar_bottom; + + draw_rectangle(target, slider_rect, ui_style.dim); + + slider_rect.x0 = x; + slider_rect.x1 = click_rect.x1; + draw_rectangle(target, slider_rect, ui_style.pop1); + } + + if (show_ticks){ + f32_Rect tick; + tick.x0 = (real32)click_rect.x0 - 1; + tick.x1 = (real32)click_rect.x0 + 1; + tick.y0 = (real32)bar_top - 3; + tick.y1 = (real32)bar_bottom + 3; + + for (i32 i = 0; i < v; ++i){ + draw_rectangle(target, tick, ui_style.dim); + tick.x0 += tick_step; + tick.x1 += tick_step; + } + + for (i32 i = v; i <= max; ++i){ + draw_rectangle(target, tick, ui_style.pop1); + tick.x0 += tick_step; + tick.x1 += tick_step; + } + } + } + else{ + if (show_bar){ + i32_Rect slider_rect; + slider_rect.x0 = click_rect.x0; + slider_rect.y0 = bar_top; + slider_rect.y1 = bar_bottom; + + Edit_Step *history = undo->history.edits; + i32 block_count = undo->history_block_count; + Edit_Step *step = history; + for (i32 i = 0; i < block_count; ++i){ + u32 color; + if (step->type == ED_REDO || + step->type == ED_UNDO) color = ui_style.pop1; + else color = ui_style.dim; + + real32 L; + if (i + 1 == block_count){ + L = 1.f; + }else{ + step = history + step->next_block; + L = unlerp(0.f, (real32)(step - history), (real32)max); + } + if (L > 1.f) L = 1.f; + i32 x = FLOOR32(lerp((real32)click_rect.x0, L, (real32)click_rect.x1)); + + slider_rect.x1 = x; + draw_rectangle(target, slider_rect, color); + slider_rect.x0 = slider_rect.x1; + + if (L == 1.f) break; + } + } + + if (show_ticks){ + f32_Rect tick; + tick.x0 = (real32)click_rect.x0 - 1; + tick.x1 = (real32)click_rect.x0 + 1; + tick.y0 = (real32)bar_top - 3; + tick.y1 = (real32)bar_bottom + 3; + + Edit_Step *history = undo->history.edits; + u32 color = ui_style.dim; + for (i32 i = 0; i <= max; ++i){ + if (i != max){ + if (history[i].type == ED_REDO) color = ui_style.pop1; + else if (history[i].type == ED_UNDO || + history[i].type == ED_NORMAL) color = ui_style.pop2; + else color = ui_style.dim; + } + draw_rectangle(target, tick, color); + tick.x0 += tick_step; + tick.x1 += tick_step; + } + } + } + + i32_Rect slider_handle; + slider_handle.x0 = x - 2; + slider_handle.x1 = x + 2; + slider_handle.y0 = click_rect.y0; + slider_handle.y1 = click_rect.y1; + + draw_rectangle(target, slider_handle, ui_style.bright); + } + } + + return result; +} + +internal void +do_label(UI_State *state, UI_Layout *layout, char *text, int text_size, f32 height = 2.f){ + Style *style = state->style; + i16 font_id = state->font_id; + i32 line_height = get_font_info(state->font_set, font_id)->height; + i32_Rect label = layout_rect(layout, FLOOR32(line_height * height)); + + if (!state->input_stage){ + Render_Target *target = state->target; + u32 back = style->main.margin_color; + u32 fore = style->main.default_color; + draw_rectangle(target, label, back); + i32 height = label.y1 - label.y0; + + String textstr = make_string(text, text_size); + draw_string(target, font_id, textstr, label.x0, + label.y0 + (height - line_height)/2, fore); + } +} + +inline void +do_label(UI_State *state, UI_Layout *layout, String text, f32 height = 2.f){ + do_label(state, layout, text.str, text.size, height); +} + +internal void +do_scroll_bar(UI_State *state, i32_Rect rect){ + i32 id = 1; + i32 w = (rect.x1 - rect.x0); + i32 h = (rect.y1 - rect.y0); + + i32_Rect top_arrow, bottom_arrow; + top_arrow.x0 = rect.x0; + top_arrow.x1 = rect.x1; + top_arrow.y0 = rect.y0; + top_arrow.y1 = top_arrow.y0 + w; + + bottom_arrow.x0 = rect.x0; + bottom_arrow.x1 = rect.x1; + bottom_arrow.y1 = rect.y1; + bottom_arrow.y0 = bottom_arrow.y1 - w; + + f32 space_h = (f32)(bottom_arrow.y0 - top_arrow.y1); + if (space_h <= w) return; + + i32 slider_h = w; + + f32 view_hmin = 0; + f32 view_hmax = state->height - h; + f32 L = unlerp(view_hmin, state->view_y, view_hmax); + + f32 slider_hmin = (f32)top_arrow.y1; + f32 slider_hmax = (f32)bottom_arrow.y0 - slider_h; + f32 S = lerp(slider_hmin, L, slider_hmax); + + i32_Rect slider; + slider.x0 = rect.x0; + slider.x1 = rect.x1; + slider.y0 = FLOOR32(S); + slider.y1 = slider.y0 + slider_h; + + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + state->view_y = + ui_do_vscroll_input(state, top_arrow, bottom_arrow, slider, wid, state->view_y, + (f32)(get_font_info(state->font_set, state->font_id)->height), + slider_hmin, slider_hmax, view_hmin, view_hmax); + } + else{ + Render_Target *target = state->target; + + f32 x0, y0, x1, y1, x2, y2; + f32 w_1_2 = w*.5f; + f32 w_1_3 = w*.333333f; + f32 w_2_3 = w*.666667f; + + + UI_Style ui_style = get_ui_style(state->style); + u32 outline, back, fore; + + outline = ui_style.bright; + + wid.sub_id2 = 0; + + x0 = (w_1_2 + top_arrow.x0); + x1 = (w_1_3 + top_arrow.x0); + x2 = (w_2_3 + top_arrow.x0); + + ++wid.sub_id2; + y0 = (w_1_3 + top_arrow.y0); + y1 = (w_2_3 + top_arrow.y0); + y2 = (w_2_3 + top_arrow.y0); + get_colors(state, &back, &fore, wid, ui_style); + draw_rectangle(target, top_arrow, back); + draw_rectangle_outline(target, top_arrow, outline); + + ++wid.sub_id2; + y0 = (w_2_3 + bottom_arrow.y0); + y1 = (w_1_3 + bottom_arrow.y0); + y2 = (w_1_3 + bottom_arrow.y0); + get_colors(state, &back, &fore, wid, ui_style); + draw_rectangle(target, bottom_arrow, back); + draw_rectangle_outline(target, bottom_arrow, outline); + + ++wid.sub_id2; + get_colors(state, &back, &fore, wid, ui_style); + draw_rectangle(target, slider, back); + draw_rectangle_outline(target, slider, outline); + + draw_rectangle_outline(target, rect, outline); + } +} + +internal void +draw_gradient_slider(Render_Target *target, Vec4 base, i32 channel, + i32 steps, f32 top, f32_Rect slider, b32 hsla){ + Vec4 low, high; + f32 *lowv, *highv; + f32 x; + f32 next_x; + f32 x_step; + f32 v_step; + f32 m; + + x = (real32)slider.x0; + x_step = (real32)(slider.x1 - slider.x0) / steps; + v_step = top / steps; + m = 1.f / top; + lowv = &low.v[channel]; + highv = &high.v[channel]; + + if (hsla){ + for (i32 i = 0; i < steps; ++i){ + low = high = base; + *lowv = (i * v_step); + *highv = *lowv + v_step; + *lowv *= m; + *highv *= m; + low = hsla_to_rgba(low); + high = hsla_to_rgba(high); + + next_x = x + x_step; + draw_gradient_2corner_clipped( + target, x, slider.y0, next_x, slider.y1, + low, high); + x = next_x; + } + } + else{ + for (i32 i = 0; i < steps; ++i){ + low = high = base; + *lowv = (i * v_step); + *highv = *lowv + v_step; + *lowv *= m; + *highv *= m; + + next_x = x + x_step; + draw_gradient_2corner_clipped( + target, x, slider.y0, next_x, slider.y1, + low, high); + x = next_x; + } + } +} + +inline void +draw_hsl_slider(Render_Target *target, Vec4 base, i32 channel, + i32 steps, f32 top, f32_Rect slider){ + draw_gradient_slider(target, base, channel, steps, top, slider, 1); +} + +inline void +draw_rgb_slider(Render_Target *target, Vec4 base, i32 channel, + i32 steps, f32 top, f32_Rect slider){ + draw_gradient_slider(target, base, channel, steps, top, slider, 0); +} + +internal b32 +do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Hot_Directory *hot_directory, b32 try_to_match, b32 case_sensitive, char *end){ + b32 result = 0; + Style *style = state->style; + String *string = &hot_directory->string; + + i16 font_id = state->font_id; + i32 line_height = get_font_info(state->font_set, font_id)->height; + i32_Rect box = layout_rect(layout, line_height + 2); + + if (state->input_stage){ + if (ui_do_file_field_input(system, state, hot_directory, try_to_match, case_sensitive)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + u32 back = style->main.margin_color; + u32 fore = style->main.default_color; + u32 special = style->main.special_character_color; + draw_rectangle(target, box, back); + i32 x = box.x0; + x = draw_string(target, font_id, string->str, x, box.y0, fore); + if (end) draw_string(target, font_id, end, x, box.y0, special); + } + + layout->y = box.y1; + return result; +} + +internal b32 +do_main_string_box(System_Functions *system, UI_State *state, UI_Layout *layout, String *string){ + b32 result = 0; + Style *style = state->style; + + i16 font_id = state->font_id; + i32 line_height = get_font_info(state->font_set, font_id)->height; + i32_Rect box = layout_rect(layout, line_height + 2); + + if (state->input_stage){ + if (ui_do_line_field_input(system, state, string)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + u32 back = style->main.margin_color; + u32 fore = style->main.default_color; + draw_rectangle(target, box, back); + i32 x = box.x0; + x = draw_string(target, font_id, string->str, x, box.y0, fore); + } + + layout->y = box.y1; + return result; +} + +internal b32 +do_list_option(i32 id, UI_State *state, UI_Layout *layout, String text){ + b32 result = 0; + Style *style = state->style; + + i16 font_id = state->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + + i32_Rect box = layout_rect(layout, character_h*2); + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + if (ui_do_button_input(state, box, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + i32_Rect inner = get_inner_rect(box, 3); + u32 back, outline, fore, pop; + back = style->main.back_color; + fore = style->main.default_color; + pop = style->main.file_info_style.pop2_color; + if (is_hover(state, wid)) outline = style->main.margin_active_color; + else outline = style->main.margin_color; + + draw_rectangle(target, inner, back); + i32 x = inner.x0, y = box.y0 + character_h/2; + x = draw_string(target, font_id, text, x, y, fore); + draw_margin(target, box, inner, outline); + } + + layout->y = box.y1; + return result; +} + +internal b32 +do_checkbox_list_option(i32 id, UI_State *state, UI_Layout *layout, String text, b32 is_on){ + b32 result = 0; + Style *style = state->style; + + i16 font_id = state->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + + i32_Rect box = layout_rect(layout, character_h*2); + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + if (ui_do_button_input(state, box, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + i32_Rect inner = get_inner_rect(box, 3); + u32 back, outline, fore, pop, box_color; + back = style->main.back_color; + fore = style->main.default_color; + pop = style->main.file_info_style.pop2_color; + if (is_hover(state, wid)) outline = style->main.margin_active_color; + else outline = style->main.margin_color; + box_color = style->main.margin_active_color; + + draw_rectangle(target, inner, back); + + i32_Rect square; + square = get_inner_rect(inner, character_h/3); + square.x1 = square.x0 + (square.y1 - square.y0); + if (is_on) draw_rectangle(target, square, box_color); + else draw_margin(target, square, 1, box_color); + + i32 x = square.x1 + 3; + i32 y = box.y0 + character_h/2; + x = draw_string(target, font_id, text, x, y, fore); + draw_margin(target, box, inner, outline); + } + + layout->y = box.y1; + return result; +} + + +internal b32 +do_file_option(i32 id, UI_State *state, UI_Layout *layout, String filename, b32 is_folder, String extra, char slash){ + b32 result = 0; + Style *style = state->style; + i16 font_id = state->font_id; + i32 character_h = get_font_info(state->font_set, font_id)->height; + char slash_buf[2] = { slash, 0 }; + + i32_Rect box = layout_rect(layout, character_h*2); + Widget_ID wid = make_id(state, id); + + if (state->input_stage){ + if (ui_do_button_input(state, box, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = state->target; + i32_Rect inner = get_inner_rect(box, 3); + u32 back, outline, fore, pop; + back = style->main.back_color; + fore = style->main.default_color; + pop = style->main.file_info_style.pop2_color; + if (is_hover(state, wid)) outline = style->main.margin_active_color; + else outline = style->main.margin_color; + + draw_rectangle(target, inner, back); + i32 x = inner.x0, y = box.y0 + character_h/2; + x = draw_string(target, font_id, filename, x, y, fore); + if (is_folder) x = draw_string(target, font_id, slash_buf, x, y, fore); + draw_string(target, font_id, extra, x, y, pop); + draw_margin(target, box, inner, outline); + } + + layout->y = box.y1; + return result; +} + +internal b32 +do_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Hot_Directory *hot_dir, b32 has_filter, b32 try_to_match, b32 case_sensitive, + b32 *new_dir, b32 *selected, char *end){ + b32 result = 0; + File_List *files = &hot_dir->file_list; + + if (do_main_file_box(system, state, layout, hot_dir, try_to_match, case_sensitive, end)){ + *selected = 1; + terminate_with_null(&hot_dir->string); + } + else{ + persist String p4c_extension = make_lit_string("p4c"); + persist String message_loaded = make_lit_string(" LOADED"); + persist String message_unsaved = make_lit_string(" LOADED *"); + persist String message_unsynced = make_lit_string(" LOADED !"); + persist String message_nothing = {}; + + char front_name_space[256]; + String front_name = make_fixed_width_string(front_name_space); + get_front_of_directory(&front_name, hot_dir->string); + + Absolutes absolutes; + get_absolutes(front_name, &absolutes, 1, 1); + + char full_path_[256]; + String full_path = make_fixed_width_string(full_path_); + get_path_of_directory(&full_path, hot_dir->string); + i32 restore_size = full_path.size; + + i32 i; + File_Info *info, *end; + end = files->infos + files->count; + for (info = files->infos, i = 0; info != end; ++info, ++i){ + String filename = info->filename; + + append(&full_path, filename); + terminate_with_null(&full_path); + + Editing_File *file = working_set_contains(state->working_set, full_path); + full_path.size = restore_size; + + b8 is_folder = (info->folder != 0); + b8 ext_match = (match(file_extension(filename), p4c_extension) != 0); + b8 name_match = (filename_match(front_name, &absolutes, filename, case_sensitive) != 0); + b8 is_loaded = (file != 0 && file_is_ready(file)); + + String message = message_nothing; + if (is_loaded){ + switch (buffer_get_sync(file)){ + case SYNC_GOOD: message = message_loaded; break; + case SYNC_BEHIND_OS: message = message_unsynced; break; + case SYNC_UNSAVED: message = message_unsaved; break; + } + } + + if ((is_folder || !has_filter || ext_match) && name_match){ + if (do_file_option(100+i, state, layout, filename, is_folder, message, system->slash)){ + result = 1; + hot_directory_clean_end(hot_dir); + append(&hot_dir->string, filename); + if (is_folder){ + *new_dir = 1; + append(&hot_dir->string, system->slash); + } + else{ + *selected = 1; + } + terminate_with_null(&hot_dir->string); + } + } + } + } + + return result; +} + +internal b32 +do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layout, + Working_Set *working_set, String *string, b32 *selected){ + b32 result = 0; + + if (do_main_string_box(system, state, layout, string)){ + *selected = 1; + terminate_with_null(string); + } + else{ + persist String message_unsaved = make_lit_string(" *"); + persist String message_unsynced = make_lit_string(" !"); + persist String message_nothing = {}; + + Absolutes absolutes; + get_absolutes(*string, &absolutes, 1, 1); + + Editing_File *file; + File_Node *node, *used_nodes; + i32 i = 0; + used_nodes = &working_set->used_sentinel; + + for (dll_items(node, used_nodes)){ + file = (Editing_File*)node; + Assert(!file->state.is_dummy); + + String message = message_nothing; + switch (buffer_get_sync(file)){ + case SYNC_BEHIND_OS: message = message_unsynced; break; + case SYNC_UNSAVED: message = message_unsaved; break; + } + + if (filename_match(*string, &absolutes, file->name.live_name, 1)){ + if (do_file_option(100+i, state, layout, file->name.live_name, 0, message, system->slash)){ + result = 1; + *selected = 1; + copy(string, file->name.source_path); + terminate_with_null(string); + } + } + + ++i; + } + } + + return result; +} + +struct Super_Color{ + Vec4 hsla; + Vec4 rgba; + u32 *out; +}; + +internal Super_Color +super_color_create(u32 packed){ + Super_Color result = {}; + result.rgba = unpack_color4(packed); + result.hsla = rgba_to_hsla(result.rgba); + return result; +} + +internal void +super_color_post_hsla(Super_Color *color, Vec4 hsla){ + color->hsla = hsla; + if (hsla.h == 1.f) + hsla.h = 0.f; + color->rgba = hsla_to_rgba(hsla); + *color->out = pack_color4(color->rgba); +} + +internal void +super_color_post_rgba(Super_Color *color, Vec4 rgba){ + color->rgba = rgba; + color->hsla = rgba_to_hsla(rgba); + *color->out = pack_color4(rgba); +} + +internal void +super_color_post_packed(Super_Color *color, u32 packed){ + color->rgba = unpack_color4(packed); + color->hsla = rgba_to_hsla(color->rgba); + *color->out = packed; +} + +u32 super_color_clear_masks[] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00}; +u32 super_color_shifts[] = {16, 8, 0}; + +internal u32 +super_color_post_byte(Super_Color *color, i32 channel, u8 byte){ + u32 packed = *color->out; + packed &= super_color_clear_masks[channel]; + packed |= (byte << super_color_shifts[channel]); + super_color_post_packed(color, packed); + return packed; +} + +struct Color_Highlight{ + i32 ids[4]; +}; + +struct Library_UI{ + UI_State *state; + UI_Layout *layout; + + Font_Set *fonts; + + Style_Library *styles; + Hot_Directory *hot_directory; +}; + +struct Color_UI{ + UI_State *state; + UI_Layout *layout; + + Font_Set *fonts; + Style_Font *global_font; + + f32 hex_advance; + u32 *palette; + i32 palette_size; + + Color_Highlight highlight; + Super_Color color; + + b32 has_hover_color; + Super_Color hover_color; +}; + +enum Channel_Field_Type{ + CF_DEC, + CF_HEX +}; + +internal void +do_single_slider(i32 sub_id, Color_UI *ui, i32 channel, b32 is_rgba, + i32 grad_steps, f32 top, f32_Rect slider, f32 v_handle, + i32_Rect rect){ + f32_Rect click_box = slider; + click_box.y0 -= v_handle; + + if (ui->state->input_stage){ + real32 v; + if (ui_do_slider_input(ui->state, i32R(click_box), make_sub1(ui->state, sub_id), slider.x0, slider.x1, &v)){ + Vec4 new_color; + if (is_rgba) new_color = ui->color.rgba; + else new_color = ui->color.hsla; + new_color.v[channel] = clamp(0.f, v, 1.f); + if (is_rgba) super_color_post_rgba(&ui->color, new_color); + else super_color_post_hsla(&ui->color, new_color); + } + } + else{ + Render_Target *target = ui->state->target; + Vec4 color; + real32 x; + if (is_rgba){ + color = ui->color.rgba; + draw_rgb_slider(target, V4(0,0,0,1.f), channel, 10, 100.f, slider); + } + else{ + i32 steps; + real32 top; + if (channel == 0){ + steps = 45; + top = 360.f; + } + else{ + steps = 10; + top = 100.f; + } + color = ui->color.hsla; + draw_hsl_slider(target, color, channel, steps, top, slider); + } + + x = lerp(slider.x0, color.v[channel], slider.x1); + draw_rectangle( + target, f32R(x, slider.y0, x + 1, slider.y1), 0xff000000); + + draw_rectangle( + target, f32R(x-2, click_box.y0, x+3, slider.y0-4), 0xff777777); + } +} + +internal void +do_hsl_sliders(Color_UI *ui, i32_Rect rect){ + real32 bar_width = (real32)(rect.x1 - rect.x0 - 20); + if (bar_width > 45){ + f32_Rect slider; + real32 y; + i32 sub_id; + + real32 v_full_space = 30.f; + real32 v_half_space = 15.f; + real32 v_quarter_space = 12.f; + real32 v_handle = 9.f; + + slider.x0 = rect.x0 + 10.f; + slider.x1 = slider.x0 + bar_width; + + sub_id = 0; + + i32 step_count[] = {45, 10, 10}; + real32 tops[] = {360.f, 100.f, 100.f}; + + y = rect.y0 + v_quarter_space; + for (i32 i = 0; i < 3; ++i){ + ++sub_id; + slider.y0 = y; + slider.y1 = slider.y0 + v_half_space; + do_single_slider(sub_id, ui, i, 0, step_count[i], tops[i], slider, v_handle, rect); + y += v_full_space; + } + } +} + +internal void +fill_buffer_color_channel(char *buffer, u8 x, Channel_Field_Type ftype){ + if (ftype == CF_DEC){ + u8 x0; + x0 = x / 10; + buffer[2] = (x - (10*x0)) + '0'; + x = x0; + x0 = x / 10; + buffer[1] = (x - (10*x0)) + '0'; + x = x0; + x0 = x / 10; + buffer[0] = (x - (10*x0)) + '0'; + } + else{ + u8 n; + n = x & 0xF; + buffer[1] = int_to_hexchar(n); + x >>= 4; + n = x & 0xF; + buffer[0] = int_to_hexchar(n); + } +} + +internal b32 +do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype, + i32 y, u32 color, u32 back, i32 x0, i32 x1){ + b32 result = 0; + + i16 font_id = ui->state->font_id; + i32 line_height = get_font_info(ui->state->font_set, font_id)->height; + i32_Rect hit_region; + hit_region.x0 = x0; + hit_region.x1 = x1; + hit_region.y0 = y; + hit_region.y1 = y + line_height; + + i32 digit_count; + if (ftype == CF_DEC) digit_count = 3; + else digit_count = 2; + + Render_Target *target = ui->state->target; + + if (ui->state->input_stage){ + i32 indx; + ui_do_subdivided_button_input(ui->state, hit_region, digit_count, + make_sub1(ui->state, sub_id), 1, &indx); + } + else{ + if (ui->state->hover.sub_id1 == sub_id && ui->state->selected.sub_id1 != sub_id){ + draw_rectangle(target, hit_region, back); + } + } + + char string_buffer[4]; + string_buffer[digit_count] = 0; + fill_buffer_color_channel(string_buffer, *channel, ftype); + + if (ui->state->selected.sub_id1 == sub_id){ + i32 indx = ui->state->selected.sub_id2; + if (ui->state->input_stage){ + Key_Summary *keys = ui->state->keys; + for (i32 key_i = 0; key_i < keys->count; ++key_i){ + Key_Event_Data key = get_single_key(keys, key_i); + + if (key.keycode == key_right){ + ++indx; + if (indx > digit_count-1) indx = 0; + } + if (key.keycode == key_left){ + --indx; + if (indx < 0) indx = digit_count-1; + } + + i32 new_value = *channel; + if (key.keycode == key_up || key.keycode == key_down){ + i32 place = digit_count-1-indx; + i32 base = (ftype == CF_DEC)?10:0x10; + i32 step_amount = 1; + while (place > 0){ + step_amount *= base; + --place; + } + if (key.keycode == key_down){ + step_amount = 0 - step_amount; + } + new_value += step_amount; + } + + u8 c = (u8)key.character; + bool32 is_good = (ftype == CF_DEC)?char_is_numeric(c):char_is_hex(c); + if (is_good){ + string_buffer[indx] = c; + if (ftype == CF_DEC) + new_value = str_to_int(make_string(string_buffer, 3)); + else + new_value = hexstr_to_int(make_string(string_buffer, 2)); + ++indx; + if (indx > digit_count-1) indx = 0; + } + + if (c == '\n'){ + switch (sub_id){ + case 1: case 2: + case 4: case 5: + ui->state->sub_id1_change = sub_id + 3; break; + + case 7: case 8: + ui->state->sub_id1_change = sub_id - 6; break; + } + } + + if (new_value != *channel){ + if (new_value > 255){ + *channel = 255; + } + else if (new_value < 0){ + *channel = 0; + } + else{ + *channel = (u8)new_value; + } + fill_buffer_color_channel(string_buffer, *channel, ftype); + result = 1; + } + ui->state->selected.sub_id2 = indx; + } + } + else{ + f32_Rect r = f32R(hit_region); + r.x0 += indx*ui->hex_advance+1; + r.x1 = r.x0+ui->hex_advance+1; + draw_rectangle(target, r, back); + } + } + + if (!ui->state->input_stage) + draw_string_mono(target, font_id, string_buffer, + (real32)x0 + 1, (real32)y, ui->hex_advance, + color); + + return result; +} + +internal void +do_rgb_sliders(Color_UI *ui, i32_Rect rect){ + i32 dec_x0, dec_x1; + dec_x0 = rect.x0 + 10; + dec_x1 = TRUNC32(dec_x0 + ui->hex_advance*3 + 2); + + i32 hex_x0, hex_x1; + hex_x0 = dec_x1 + 10; + hex_x1 = TRUNC32(hex_x0 + ui->hex_advance*2 + 2); + + rect.x0 = hex_x1; + real32 bar_width = (real32)(rect.x1 - rect.x0 - 20); + + f32_Rect slider; + f32 y; + i32 sub_id; + u8 channel; + + real32 v_full_space = 30.f; + real32 v_half_space = 15.f; + real32 v_quarter_space = 12.f; + real32 v_handle = 9.f; + + u32 packed_color = *ui->color.out; + + y = rect.y0 + v_quarter_space; + slider.x0 = rect.x0 + 10.f; + slider.x1 = slider.x0 + bar_width; + + sub_id = 0; + + persist i32 shifts[3] = { 16, 8, 0 }; + persist u32 fore_colors[3] = { 0xFFFF0000, 0xFF00FF00, 0xFF1919FF }; + persist u32 back_colors[3] = { 0xFF222222, 0xFF222222, 0xFF131313 }; + + for (i32 i = 0; i < 3; ++i){ + i32 shift = shifts[i]; + u32 fore = fore_colors[i]; + u32 back = back_colors[i]; + + ++sub_id; + channel = (packed_color >> shift) & 0xFF; + if (do_channel_field(sub_id, ui, &channel, CF_DEC, + (i32)y, fore, back, dec_x0, dec_x1)) + super_color_post_byte(&ui->color, i, channel); + + ++sub_id; + channel = (packed_color >> shift) & 0xFF; + if (do_channel_field(sub_id, ui, &channel, CF_HEX, + (i32)y, fore, back, hex_x0, hex_x1)) + super_color_post_byte(&ui->color, i, channel); + + ++sub_id; + slider.y0 = y; + slider.y1 = slider.y0 + v_half_space; + if (bar_width > 45.f) + do_single_slider(sub_id, ui, i, 1, 10, 100.f, slider, v_handle, rect); + y += v_full_space; + } +} + +struct Blob_Layout{ + i32_Rect rect; + i32 x, y; + i32 size, space; +}; + +internal void +begin_layout(Blob_Layout *layout, i32_Rect rect){ + layout->rect = rect; + layout->x = rect.x0 + 10; + layout->y = rect.y0; + layout->size = 20; + layout->space = 5; +} + +internal void +do_blob(Color_UI *ui, Blob_Layout *layout, u32 color, bool32 *set_me, i32 sub_id){ + i32_Rect rect = layout->rect; + f32_Rect blob; + blob.x0 = (real32)layout->x; + blob.y0 = (real32)layout->y; + blob.x1 = blob.x0 + layout->size; + blob.y1 = blob.y0 + layout->size; + + layout->y += layout->size + layout->space; + if (layout->y + layout->size + layout->space*2 > rect.y1){ + layout->y = rect.y0; + layout->x += layout->size + layout->space; + } + + if (ui->state->input_stage){ + bool32 right = 0; + if (ui_do_button_input(ui->state, i32R(blob), make_sub1(ui->state, sub_id), 0, &right)){ + super_color_post_packed(&ui->color, color); + } + else if (right) *set_me = 1; + } + else{ + Render_Target *target = ui->state->target; + draw_rectangle(target, blob, color); + persist u32 silver = 0xFFa0a0a0; + draw_rectangle_outline(target, blob, silver); + } +} + +inline void +do_blob(Color_UI *ui, Blob_Layout *layout, u32 *color, bool32 *set_me){ + i32 sub_id = (i32)((char*)color - (char*)ui->state->style); + do_blob(ui, layout, *color, set_me, sub_id); +} + +internal void +do_v_divide(Color_UI *ui, Blob_Layout *layout, i32 width){ + i32_Rect rect = layout->rect; + if (layout->y > rect.y0){ + layout->x += layout->size + layout->space; + } + layout->x += width; + layout->y = rect.y0; +} + +internal void +do_palette(Color_UI *ui, i32_Rect rect){ + Style *style = ui->state->style; + Blob_Layout layout; + begin_layout(&layout, rect); + bool32 set_me; + + do_blob(ui, &layout, &style->main.back_color, &set_me); + do_blob(ui, &layout, &style->main.margin_color, &set_me); + do_blob(ui, &layout, &style->main.margin_active_color, &set_me); + + do_blob(ui, &layout, &style->main.cursor_color, &set_me); + do_blob(ui, &layout, &style->main.at_cursor_color, &set_me); + do_blob(ui, &layout, &style->main.mark_color, &set_me); + + do_blob(ui, &layout, &style->main.highlight_color, &set_me); + do_blob(ui, &layout, &style->main.at_highlight_color, &set_me); + + do_blob(ui, &layout, &style->main.default_color, &set_me); + do_blob(ui, &layout, &style->main.comment_color, &set_me); + do_blob(ui, &layout, &style->main.keyword_color, &set_me); + do_blob(ui, &layout, &style->main.str_constant_color, &set_me); + do_blob(ui, &layout, &style->main.char_constant_color, &set_me); + do_blob(ui, &layout, &style->main.int_constant_color, &set_me); + do_blob(ui, &layout, &style->main.float_constant_color, &set_me); + do_blob(ui, &layout, &style->main.bool_constant_color, &set_me); + do_blob(ui, &layout, &style->main.include_color, &set_me); + do_blob(ui, &layout, &style->main.preproc_color, &set_me); + do_blob(ui, &layout, &style->main.special_character_color, &set_me); + + do_blob(ui, &layout, &style->main.highlight_junk_color, &set_me); + do_blob(ui, &layout, &style->main.highlight_white_color, &set_me); + + do_blob(ui, &layout, &style->main.paste_color, &set_me); + + do_blob(ui, &layout, &style->main.file_info_style.bar_color, &set_me); + do_blob(ui, &layout, &style->main.file_info_style.base_color, &set_me); + do_blob(ui, &layout, &style->main.file_info_style.pop1_color, &set_me); + do_blob(ui, &layout, &style->main.file_info_style.pop2_color, &set_me); + + do_v_divide(ui, &layout, 20); + + if (!ui->state->input_stage){ + Render_Target *target = ui->state->target; + draw_string(target, ui->state->font_id, "Global Palette: right click to save color", + layout.x, layout.rect.y0, style->main.default_color); + } + + layout.rect.y0 += layout.size + layout.space; + layout.y = layout.rect.y0; + i32 palette_size = ui->palette_size + 1000; + u32 *color = ui->palette; + for (i32 i = 1000; i < palette_size; ++i, ++color){ + set_me = 0; + do_blob(ui, &layout, *color, &set_me, i); + if (set_me){ + *color = *ui->color.out; + ui->state->redraw = 1; + } + } +} + +internal void +do_sub_button(i32 id, Color_UI *ui, char *text){ + i16 font_id = ui->state->font_id; + i32 line_height = get_font_info(ui->state->font_set, font_id)->height; + i32_Rect rect = layout_rect(ui->layout, line_height + 2); + + if (ui->state->input_stage){ + ui_do_button_input(ui->state, rect, make_sub0(ui->state, id), 1); + } + else{ + Render_Target *target = ui->state->target; + + u32 back_color, text_color; + text_color = 0xFFDDDDDD; + if (ui->state->selected.sub_id0 == id){ + back_color = 0xFF444444; + } + else if (ui->state->hover.sub_id0 == id){ + back_color = 0xFF222222; + } + else{ + back_color = 0xFF111111; + } + + draw_rectangle(target, rect, back_color); + draw_string(target, font_id, text, rect.x0, rect.y0 + 1, + text_color); + } +} + +internal void +do_color_adjuster(Color_UI *ui, u32 *color, + u32 text_color, u32 back_color, char *name){ + i32 id = raw_ptr_dif(color, ui->state->style); + i16 font_id = ui->state->font_id; + i32 character_h = get_font_info(ui->state->font_set, font_id)->height; + u32 text = 0, back = 0; + + i32_Rect bar = layout_rect(ui->layout, character_h); + + if (ui->state->input_stage){ + if (ui_do_button_input(ui->state, bar, make_id(ui->state, id), 1)){ + ui->has_hover_color = 1; + ui->hover_color = super_color_create(*color); + } + } + + else{ + Render_Target *target = ui->state->target; + u32 text_hover = 0xFF101010; + u32 back_hover = 0xFF999999; + if (ui->state->selected.id != id && ui->state->hover.id == id){ + text = text_hover; + back = back_hover; + } + else{ + text = text_color; + back = back_color; + } + + draw_rectangle(target, bar, back); + i32 end_pos = draw_string(target, font_id, name, bar.x0, bar.y0, text); + + real32 x_spacing = ui->hex_advance; + i32_Rect temp_rect = bar; + temp_rect.x0 = temp_rect.x1 - CEIL32(x_spacing * 9.f); + if (temp_rect.x0 >= end_pos + x_spacing){ + u32 n = *color; + char full_hex_string[] = "0x000000"; + for (i32 i = 7; i >= 2; --i){ + i32 m = (n & 0xF); + n >>= 4; + full_hex_string[i] = int_to_hexchar(m); + } + draw_string_mono(target, font_id, full_hex_string, + (f32)temp_rect.x0, (f32)bar.y0, + x_spacing, text); + } + + for (i32 i = 0; i < ArrayCount(ui->highlight.ids); ++i){ + if (ui->highlight.ids[i] == id){ + draw_rectangle_outline(target, f32R(bar), text_color); + break; + } + } + } + + if (ui->state->selected.id == id){ + Render_Target *target = ui->state->target; + i32_Rect expanded = layout_rect(ui->layout, 115 + (character_h + 2)); + UI_Layout_Restore restore = begin_sub_layout(ui->layout, expanded); + + ui->color.out = color; + + if (ui->state->input_stage){ + if (ui->state->selected.sub_id0 == 0){ + ui->state->selected.sub_id0 = 1; + } + } + else{ + draw_rectangle(target, expanded, 0xff000000); + } + + begin_row(ui->layout, 3); + do_sub_button(1, ui, "HSL"); + do_sub_button(2, ui, "RGB"); + do_sub_button(3, ui, "Palette"); + + i32_Rect sub_rect; + sub_rect = expanded; + sub_rect.y0 += 10 + character_h; + + switch (ui->state->selected.sub_id0){ + case 1: do_hsl_sliders(ui, sub_rect); break; + case 2: do_rgb_sliders(ui, sub_rect); break; + case 3: do_palette(ui, sub_rect); break; + } + + end_sub_layout(restore); + } +} + +internal void +do_style_name(Color_UI *ui){ + i32 id = -3; + + i16 font_id = ui->state->font_id; + i32 line_height = get_font_info(ui->state->font_set, font_id)->height; + + i32_Rect srect = layout_rect(ui->layout, line_height); + + Widget_ID wid = make_id(ui->state, id); + b32 selected = is_selected(ui->state, wid); + + if (ui->state->input_stage){ + if (!selected){ + ui_do_button_input(ui->state, srect, wid, 1); + } + else{ + Style *style = ui->state->style; + if (ui_do_text_field_input(ui->state, &style->name)){ + ui->state->selected = {}; + } + } + } + else{ + Render_Target *target = ui->state->target; + Style *style = ui->state->style; + u32 back, fore_text, fore_label; + if (selected){ + back = 0xFF000000; + fore_label = 0xFF808080; + fore_text = 0xFFFFFFFF; + } + else if (is_hover(ui->state, wid)){ + back = 0xFF999999; + fore_text = fore_label = 0xFF101010; + } + else{ + back = style->main.back_color; + fore_text = fore_label = style->main.default_color; + } + + draw_rectangle(target, srect, back); + i32 x = srect.x0; + x = draw_string(target, font_id, "NAME: ", + x, srect.y0, fore_label); + x = draw_string(target, font_id, style->name.str, + x, srect.y0, fore_text); + } +} + +internal b32 +do_font_option(Color_UI *ui, i16 font_id){ + b32 result = 0; + Font_Info *info = get_font_info(ui->state->font_set, font_id); + + i32 sub_id = (i32)(i64)(info); + i32_Rect orect = layout_rect(ui->layout, info->height); + + Widget_ID wid = make_sub0(ui->state, sub_id); + if (ui->state->input_stage){ + if (ui_do_button_input(ui->state, orect, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = ui->state->target; + u32 back, fore; + if (is_hover(ui->state, wid)){ + back = 0xFF999999; + fore = 0xFF101010; + } + else{ + back = 0xFF000000; + fore = 0xFFFFFFFF; + } + draw_rectangle(target, orect, back); + i32 x = orect.x0; + x = draw_string(target, font_id, "->", x, orect.y0, fore); + draw_string(target, font_id, info->name.str, x, orect.y0, fore); + } + + return result; +} + +internal void +do_font_switch(Color_UI *ui){ + i32 id = -2; + Render_Target *target = ui->state->target; + Font_Set *font_set = ui->state->font_set; + + i16 font_id = ui->state->font_id; + Font_Info *info = get_font_info(font_set, font_id); + i32 character_h = info->height; + + i32_Rect srect = layout_rect(ui->layout, character_h); + Widget_ID wid = make_id(ui->state, id); + + if (ui->state->input_stage){ + ui_do_button_input(ui->state, srect, wid, 1); + } + else{ + Style *style = ui->state->style; + u32 back, fore; + if (is_hover(ui->state, wid) && !is_selected(ui->state, wid)){ + back = 0xFF999999; + fore = 0xFF101010; + } + else{ + back = style->main.back_color; + fore = style->main.default_color; + } + draw_rectangle(target, srect, back); + i32 x = srect.x0; + x = draw_string(target, font_id, "FONT: ", + x, srect.y0, fore); + x = draw_string(target, font_id, info->name.str, + x, srect.y0, fore); + } + + if (is_selected(ui->state, wid)){ + srect = layout_rect(ui->layout, character_h/2); + if (!ui->state->input_stage) + draw_rectangle(target, srect, 0xFF000000); + + i32 count = font_set->count + 1; + + for (i16 i = 1; i < count; ++i){ + if (i == font_id) continue; + if (do_font_option(ui, i)){ + ui->global_font->font_id = i; + ui->global_font->font_changed = 1; + } + } + + srect = layout_rect(ui->layout, character_h/2); + if (!ui->state->input_stage) + draw_rectangle(target, srect, 0xFF000000); + } +} + +internal b32 +do_style_preview(Library_UI *ui, Style *style, i32 toggle = -1){ + b32 result = 0; + i32 id; + if (style == ui->state->style) id = 2; + else id = raw_ptr_dif(style, ui->styles->styles) + 100; + + i16 font_id = ui->state->font_id; + Font_Info *info = get_font_info(ui->state->font_set, font_id); + + i32_Rect prect = layout_rect(ui->layout, info->height*3 + 6); + + Widget_ID wid = make_id(ui->state, id); + + if (ui->state->input_stage){ + if (ui_do_button_input(ui->state, prect, wid, 0)){ + result = 1; + } + } + else{ + Render_Target *target = ui->state->target; + u32 margin_color = style->main.margin_color; + if (is_hover(ui->state, wid)){ + margin_color = style->main.margin_active_color; + } + + i32_Rect inner; + if (toggle != -1){ + i32_Rect toggle_box = prect; + toggle_box.x1 = toggle_box.x0 + info->height*2 + 6; + prect.x0 = toggle_box.x1; + + inner = get_inner_rect(toggle_box, 3); + draw_margin(target, toggle_box, inner, margin_color); + draw_rectangle(target, inner, style->main.back_color); + + i32 d; + d = info->height/2; + i32_Rect b; + b.x0 = (inner.x1 + inner.x0)/2 - d; + b.y0 = (inner.y1 + inner.y0)/2 - d; + b.x1 = b.x0 + info->height; + b.y1 = b.y0 + info->height; + if (toggle) draw_rectangle(target, b, margin_color); + else draw_rectangle_outline(target, b, margin_color); + } + + inner = get_inner_rect(prect, 3); + draw_margin(target, prect, inner, margin_color); + draw_rectangle(target, inner, style->main.back_color); + + i32 text_y = inner.y0; + i32 text_x = inner.x0; + text_x = draw_string(target, font_id, style->name.str, + text_x, text_y, style->main.default_color); + i32 font_x = (i32)(inner.x1 - font_string_width(target, font_id, info->name.str)); + if (font_x > text_x + 10) + draw_string(target, font_id, info->name.str, + font_x, text_y, style->main.default_color); + + text_x = inner.x0; + text_y += info->height; + text_x = draw_string(target, font_id, "if ", text_x, text_y, + style->main.keyword_color); + text_x = draw_string(target, font_id, "(x < ", text_x, text_y, + style->main.default_color); + text_x = draw_string(target, font_id, "0", text_x, text_y, + style->main.int_constant_color); + text_x = draw_string(target, font_id, ") { x = ", text_x, text_y, + style->main.default_color); + text_x = draw_string(target, font_id, "0", text_x, text_y, + style->main.int_constant_color); + text_x = draw_string(target, font_id, "; } ", text_x, text_y, + style->main.default_color); + text_x = draw_string(target, font_id, "// comment", text_x, text_y, + style->main.comment_color); + + text_x = inner.x0; + text_y += info->height; + text_x = draw_string(target, font_id, "[] () {}; * -> +-/ <>= ! && || % ^", + text_x, text_y, style->main.default_color); + } + + ui->layout->y = prect.y1; + return result; +} + + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_internal.h b/test_data/lots_of_files/4ed_internal.h new file mode 100644 index 0000000..bd88a12 --- /dev/null +++ b/test_data/lots_of_files/4ed_internal.h @@ -0,0 +1,60 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 16.05.2015 + * + * Fascilities available for development but not intended for shipping. + * + */ + +// TOP + +#if FRED_INTERNAL == 1 +#define ProfileStart_(name, start, counter, hit, thread, n, c) + +#define ProfileEnd_(name, start, counter, hit, thread) + +#define ProfileMoment_(name, counter, thread) + +#if 0 + +#define ProfileStart(name) char *_pname_##name; i64 _pstart_##name; \ + i32 _pcounter_##name; u32 _phit_##name; \ + ProfileStart_(_pname_##name, _pstart_##name, _pcounter_##name, \ + _phit_##name, system->thread_get_id(thread), \ + #name, __COUNTER__) + +#define ProfileEnd(name) ProfileEnd_(_pname_##name, _pstart_##name, \ + _pcounter_##name, _phit_##name, \ + system->thread_get_id(thread)) + +#define ProfileMoment(name, thread) ProfileMoment_(#name, __COUNTER__, thread) +#define ProfileMomentFunction() ProfileMoment_(__FUNCTION__, __COUNTER__, 0) + +#else + +#define ProfileStart(name) +#define ProfileEnd(name) +#define ProfileMoment(name) +#define ProfileMomentFunction() + +#endif + + + +struct Sys_Bubble : public Bubble{ + i32 line_number; + char *file_name; +}; + +#else + +#define ProfileStart(name) +#define ProfileEnd(name) +#define ProfileMoment(name) +#define ProfileMomentFunction() + +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_keyboard.cpp b/test_data/lots_of_files/4ed_keyboard.cpp new file mode 100644 index 0000000..54975f4 --- /dev/null +++ b/test_data/lots_of_files/4ed_keyboard.cpp @@ -0,0 +1,20 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 16.11.2014 + * + * Keyboard layer for 4coder + * + */ + +// TOP + +globalvar u8 keycode_lookup_table[255]; + +inline u8 +keycode_lookup(u8 system_code){ + return keycode_lookup_table[system_code]; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_keycodes.h b/test_data/lots_of_files/4ed_keycodes.h new file mode 100644 index 0000000..c8d6b77 --- /dev/null +++ b/test_data/lots_of_files/4ed_keycodes.h @@ -0,0 +1,30 @@ +enum Key_Code{ +key_back = 1, +key_up = 2, +key_down = 3, +key_left = 4, +key_right = 5, +key_del = 6, +key_insert = 7, +key_home = 8, +key_end = 11, +key_page_up = 12, +key_page_down = 13, +key_esc = 14, +key_f1 = 127, +key_f2 = 128, +key_f3 = 129, +key_f4 = 130, +key_f5 = 131, +key_f6 = 132, +key_f7 = 133, +key_f8 = 134, +key_f9 = 135, +key_f10 = 136, +key_f11 = 137, +key_f12 = 138, +key_f13 = 139, +key_f14 = 140, +key_f15 = 141, +key_f15 = 142, +} diff --git a/test_data/lots_of_files/4ed_layout.cpp b/test_data/lots_of_files/4ed_layout.cpp new file mode 100644 index 0000000..81d20fa --- /dev/null +++ b/test_data/lots_of_files/4ed_layout.cpp @@ -0,0 +1,313 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 19.08.2015 + * + * Panel layout and general view functions for 4coder + * + */ + +// TOP + +struct Panel_Divider{ + Panel_Divider *next; + i32 parent; + i32 which_child; + i32 child1, child2; + b32 v_divider; + i32 pos; +}; + +struct Screen_Region{ + i32_Rect full; + i32_Rect inner; + i32_Rect prev_inner; + i32 l_margin, r_margin; + i32 t_margin, b_margin; +}; + +struct Panel{ + Panel *next; + Panel *prev; + + struct View *view; + i32 parent; + i32 which_child; + + int ALLOCED; + + union{ + struct{ + i32_Rect full; + i32_Rect inner; + i32_Rect prev_inner; + i32 l_margin, r_margin; + i32 t_margin, b_margin; + }; + Screen_Region screen_region; + }; +}; + +struct Editing_Layout{ + Panel *panels; + Panel free_sentinel; + Panel used_sentinel; + Panel_Divider *dividers; + Panel_Divider *free_divider; + i32 panel_count, panel_max_count; + i32 root; + i32 active_panel; + i32 full_width, full_height; +}; + +struct Divider_And_ID{ + Panel_Divider* divider; + i32 id; +}; + +struct Panel_And_ID{ + Panel* panel; + i32 id; +}; + +internal void +panel_init(Panel *panel){ + panel->view = 0; + panel->parent = -1; + panel->which_child = 0; + panel->screen_region.full = {}; + panel->screen_region.inner = {}; + panel->screen_region.prev_inner = {}; + panel->l_margin = 3; + panel->r_margin = 3; + panel->t_margin = 3; + panel->b_margin = 3; +} + +internal Divider_And_ID +layout_alloc_divider(Editing_Layout *layout){ + Divider_And_ID result; + + Assert(layout->free_divider); + result.divider = layout->free_divider; + layout->free_divider = result.divider->next; + + *result.divider = {}; + result.divider->parent = -1; + result.divider->child1 = -1; + result.divider->child2 = -1; + result.id = (i32)(result.divider - layout->dividers); + if (layout->panel_count == 1){ + layout->root = result.id; + } + + return(result); +} + +internal Divider_And_ID +layout_get_divider(Editing_Layout *layout, i32 id){ + Divider_And_ID result; + + Assert(id >= 0 && id < layout->panel_max_count-1); + result.id = id; + result.divider = layout->dividers + id; + + return(result); +} + +internal void +layout_free_divider(Editing_Layout *layout, Panel_Divider *divider){ + divider->next = layout->free_divider; + layout->free_divider = divider; +} + +internal Panel_And_ID +layout_alloc_panel(Editing_Layout *layout){ + Panel_And_ID result = {}; + + Assert(layout->panel_count < layout->panel_max_count); + ++layout->panel_count; + + result.panel = layout->free_sentinel.next; + dll_remove(result.panel); + dll_insert(&layout->used_sentinel, result.panel); + + panel_init(result.panel); + + result.id = (i32)(result.panel - layout->panels); + + result.panel->ALLOCED = 1; + + return(result); +} + +internal void +layout_free_panel(Editing_Layout *layout, Panel *panel){ + dll_remove(panel); + dll_insert(&layout->free_sentinel, panel); + --layout->panel_count; + + panel->ALLOCED = 0; +} + +internal Divider_And_ID +layout_calc_divider_id(Editing_Layout *layout, Panel_Divider *divider){ + Divider_And_ID result; + result.divider = divider; + result.id = (i32)(divider - layout->dividers); + return result; +} + +struct Split_Result{ + Panel_Divider *divider; + Panel *panel; +}; + +internal Split_Result +layout_split_panel(Editing_Layout *layout, Panel *panel, b32 vertical){ + Split_Result result = {}; + Divider_And_ID div = {}, parent_div = {}; + Panel_And_ID new_panel = {}; + + div = layout_alloc_divider(layout); + if (panel->parent != -1){ + parent_div = layout_get_divider(layout, panel->parent); + if (panel->which_child == -1){ + parent_div.divider->child1 = div.id; + } + else{ + parent_div.divider->child2 = div.id; + } + } + + div.divider->parent = panel->parent; + div.divider->which_child = panel->which_child; + if (vertical){ + div.divider->v_divider = 1; + div.divider->pos = (panel->full.x0 + panel->full.x1) / 2; + } + else{ + div.divider->v_divider = 0; + div.divider->pos = (panel->full.y0 + panel->full.y1) / 2; + } + + new_panel = layout_alloc_panel(layout); + panel->parent = div.id; + panel->which_child = -1; + new_panel.panel->parent = div.id; + new_panel.panel->which_child = 1; + + result.divider = div.divider; + result.panel = new_panel.panel; + + return result; +} + +internal void +panel_fix_internal_area(Panel *panel){ + panel->inner.x0 = panel->full.x0 + panel->l_margin; + panel->inner.x1 = panel->full.x1 - panel->r_margin; + panel->inner.y0 = panel->full.y0 + panel->t_margin; + panel->inner.y1 = panel->full.y1 - panel->b_margin; +} + +internal void +layout_fix_all_panels(Editing_Layout *layout){ + Panel *panel; + Panel_Divider *dividers = layout->dividers; + i32 panel_count = layout->panel_count; + i32_Rect r; + i32 pos, which_child, action; + Divider_And_ID div; + + if (panel_count > 1){ + for (panel = layout->used_sentinel.next; + panel != &layout->used_sentinel; + panel = panel->next){ + + r.x0 = 0; + r.x1 = r.x0 + layout->full_width; + r.y0 = 0; + r.y1 = r.y0 + layout->full_height; + + which_child = panel->which_child; + + div.id = panel->parent; + + for (;;){ + Assert(div.id != -1); + div.divider = dividers + div.id; + pos = div.divider->pos; + + action = (div.divider->v_divider << 1) | (which_child > 0); + switch (action){ + case 0: // v_divider : 0, which_child : -1 + if (pos < r.y1) r.y1 = pos; + break; + case 1: // v_divider : 0, which_child : 1 + if (pos > r.y0) r.y0 = pos; + break; + case 2: // v_divider : 1, which_child : -1 + if (pos < r.x1) r.x1 = pos; + break; + case 3: // v_divider : 1, which_child : 1 + if (pos > r.x0) r.x0 = pos; + break; + } + + if (div.id != layout->root){ + div.id = div.divider->parent; + which_child = div.divider->which_child; + } + else{ + break; + } + } + + panel->full = r; + panel_fix_internal_area(panel); + } + } + + else{ + panel = layout->used_sentinel.next; + panel->full.x0 = 0; + panel->full.y0 = 0; + panel->full.x1 = layout->full_width; + panel->full.y1 = layout->full_height; + panel_fix_internal_area(panel); + } +} + +internal void +layout_refit(Editing_Layout *layout, i32 prev_width, i32 prev_height){ + + Panel_Divider *dividers = layout->dividers; + i32 max = layout->panel_max_count - 1; + + f32 h_ratio, v_ratio; + + Panel_Divider *divider = dividers; + i32 i; + + if (layout->panel_count > 1){ + Assert(prev_width != 0 && prev_height != 0); + + h_ratio = ((f32)layout->full_width) / prev_width; + v_ratio = ((f32)layout->full_height) / prev_height; + + for (i = 0; i < max; ++i, ++divider){ + if (divider->v_divider){ + divider->pos = ROUND32((divider->pos) * h_ratio); + } + else{ + divider->pos = ROUND32((divider->pos) * v_ratio); + } + } + } + + layout_fix_all_panels(layout); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_linux_keyboard.cpp b/test_data/lots_of_files/4ed_linux_keyboard.cpp new file mode 100644 index 0000000..5d7dbec --- /dev/null +++ b/test_data/lots_of_files/4ed_linux_keyboard.cpp @@ -0,0 +1,92 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 14.11.2015 + * + * Linux-US Keyboard layer for 4coder + * + */ + +// TOP + +#include "4ed_keyboard.cpp" + +internal void +keycode_init(Display* dpy){ +#if 0 + // NOTE(inso): these are for XInput, currently not used. + + keycode_lookup_table[KEY_BACKSPACE] = codes->back; + keycode_lookup_table[KEY_DELETE] = codes->del; + keycode_lookup_table[KEY_UP] = codes->up; + keycode_lookup_table[KEY_DOWN] = codes->down; + keycode_lookup_table[KEY_LEFT] = codes->left; + keycode_lookup_table[KEY_RIGHT] = codes->right; + keycode_lookup_table[KEY_INSERT] = codes->insert; + keycode_lookup_table[KEY_HOME] = codes->home; + keycode_lookup_table[KEY_END] = codes->end; + keycode_lookup_table[KEY_PAGEUP] = codes->page_up; + keycode_lookup_table[KEY_PAGEDOWN] = codes->page_down; + keycode_lookup_table[KEY_ESC] = codes->esc; +#endif + + // NOTE(inso): This looks a bit dumb, but it's the best way I can think of to do it, since: + // KeySyms are the type representing "virtual" keys, like XK_BackSpace, but they are 32-bit ints. + // KeyCodes are guaranteed to fit in 1 byte (and therefore the keycode_lookup_table) but + // have dynamic numbers assigned by the XServer. + // There is XKeysymToKeycode, but it only returns 1 KeyCode for a KeySym. I have my capslock + // rebound to esc, so there are two KeyCodes for the XK_Escape KeyCode but XKeysymToKeycode only + // gets one of them, hence the need for this crazy lookup which works correctly with rebound keys. + + memset(keycode_lookup_table, 0, sizeof(keycode_lookup_table)); + + struct SymMapping { + KeySym sym; + Code code; + } sym_table[] = { + { XK_BackSpace, key_back }, + { XK_Delete, key_del }, + { XK_Up, key_up }, + { XK_Down, key_down }, + { XK_Left, key_left }, + { XK_Right, key_right }, + { XK_Insert, key_insert }, + { XK_Home, key_home }, + { XK_End, key_end }, + { XK_Page_Up, key_page_up }, + { XK_Page_Down, key_page_down }, + { XK_Escape, key_esc } + }; + + const int table_size = sizeof(sym_table) / sizeof(struct SymMapping); + + int key_min, key_max, syms_per_code; + XDisplayKeycodes(dpy, &key_min, &key_max); + + int key_count = (key_max - key_min) + 1; + + KeySym* syms = XGetKeyboardMapping( + dpy, + key_min, + key_count, + &syms_per_code + ); + + if(!syms) return; + + int key = key_min; + for(int i = 0; i < key_count * syms_per_code; ++i){ + for(int j = 0; j < table_size; ++j){ + if(sym_table[j].sym == syms[i]){ + keycode_lookup_table[key + (i/syms_per_code)] = sym_table[j].code; + break; + } + } + } + + XFree(syms); + +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_math.cpp b/test_data/lots_of_files/4ed_math.cpp new file mode 100644 index 0000000..6892e94 --- /dev/null +++ b/test_data/lots_of_files/4ed_math.cpp @@ -0,0 +1,774 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 15.05.2015 + * + * Math functions for 4coder + * + */ + +// TOP + +/* + * Scalar operators + */ + +#define C_MATH 1 + +#define DEG_TO_RAD 0.0174533f + +#if C_MATH +#include <math.h> +#endif + +inline f32 +ABS(f32 x){ + if (x < 0) x = -x; + return x; +} + +inline f32 +MOD(f32 x, i32 m){ +#if C_MATH + f32 whole, frac; + frac = modff(x, &whole); + return ((i32)(whole) % m) + frac; +#endif +} + +inline f32 +SQRT(f32 x){ +#if C_MATH + return sqrt(x); +#endif +} + +inline f32 +SIN(f32 x_degrees){ +#if C_MATH + return sinf(x_degrees * DEG_TO_RAD); +#endif +} + +inline f32 +COS(f32 x_degrees){ +#if C_MATH + return cosf(x_degrees * DEG_TO_RAD); +#endif +} + +/* + * Rounding + */ + +inline i32 +TRUNC32(real32 x) { return (i32)x; } + +inline i32 +FLOOR32(real32 x) { return (i32)(x)-((x!=(i32)(x) && x<0)?1:0); } + +inline i32 +CEIL32(real32 x) { return (i32)(x)+((x!=(i32)(x) && x>0)?1:0); } + +inline i32 +ROUND32(real32 x) { return FLOOR32(x + .5f); } + +inline i32 +DIVCEIL32(i32 n, i32 d) { + i32 q = (n/d); + return q + (q*d < n); +} + +inline real32 +FRACPART32(real32 x) { return x - (i32)x; } + +inline u32 +ROUNDPOT32(u32 v){ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v; +} + +/* + * Rectangles + */ + +struct i32_Rect{ + i32 x0, y0; + i32 x1, y1; +}; + +struct f32_Rect{ + f32 x0, y0; + f32 x1, y1; +}; + +inline i32_Rect +i32R(i32 l, i32 t, i32 r, i32 b){ + i32_Rect rect; + rect.x0 = l; rect.y0 = t; + rect.x1 = r; rect.y1 = b; + return rect; +} + +inline i32_Rect +i32R(f32_Rect r){ + i32_Rect rect; + rect.x0 = (i32)r.x0; + rect.y0 = (i32)r.y0; + rect.x1 = (i32)r.x1; + rect.y1 = (i32)r.y1; + return rect; +} + +inline i32_Rect +i32XYWH(i32 x, i32 y, i32 w, i32 h){ + i32_Rect rect; + rect.x0 = x; rect.y0 = y; + rect.x1 = x+w; rect.y1 = y+h; + return rect; +} + +inline f32_Rect +f32R(f32 l, f32 t, f32 r, f32 b){ + f32_Rect rect; + rect.x0 = l; rect.y0 = t; + rect.x1 = r; rect.y1 = b; + return rect; +} + +inline f32_Rect +f32R(i32_Rect r){ + f32_Rect rect; + rect.x0 = (f32)r.x0; + rect.y0 = (f32)r.y0; + rect.x1 = (f32)r.x1; + rect.y1 = (f32)r.y1; + return rect; +} + +inline f32_Rect +f32XYWH(f32 x, f32 y, f32 w, f32 h){ + f32_Rect rect; + rect.x0 = x; rect.y0 = y; + rect.x1 = x+w; rect.y1 = y+h; + return rect; +} + +inline b32 +hit_check(i32 x, i32 y, i32 x0, i32 y0, i32 x1, i32 y1){ + return (x >= x0 && x < x1 && y >= y0 && y < y1); +} + +inline b32 +hit_check(i32 x, i32 y, i32_Rect rect){ + return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1)); +} + +inline b32 +hit_check(i32 x, i32 y, f32 x0, f32 y0, f32 x1, f32 y1){ + return (x >= x0 && x < x1 && y >= y0 && y < y1); +} + +inline b32 +hit_check(i32 x, i32 y, f32_Rect rect){ + return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1)); +} + +inline b32 +positive_area(i32_Rect rect){ + return (rect.x0 < rect.x1 && rect.y0 < rect.y1); +} + +inline i32_Rect +get_inner_rect(i32_Rect outer, i32 margin){ + i32_Rect r; + r.x0 = outer.x0 + margin; + r.y0 = outer.y0 + margin; + r.x1 = outer.x1 - margin; + r.y1 = outer.y1 - margin; + return r; +} + +inline b32 +fits_inside(i32_Rect rect, i32_Rect outer){ + return (rect.x0 >= outer.x0 && rect.x1 <= outer.x1 && + rect.y0 >= outer.y0 && rect.y1 <= outer.y1); +} + +inline i32_Rect +rect_clamp_to_rect(i32_Rect rect, i32_Rect clamp_box){ + if (rect.x0 < clamp_box.x0) rect.x0 = clamp_box.x0; + if (rect.y0 < clamp_box.y0) rect.y0 = clamp_box.y0; + if (rect.x1 > clamp_box.x1) rect.x1 = clamp_box.x1; + if (rect.y1 > clamp_box.y1) rect.y1 = clamp_box.y1; + return rect; +} + +inline i32_Rect +rect_clamp_to_rect(i32 left, i32 top, i32 right, i32 bottom, i32_Rect clamp_box){ + return rect_clamp_to_rect(i32R(left, top, right, bottom), clamp_box); +} + +/* + * Vectors + */ + +struct Vec2{ + union{ + struct{ + real32 x, y; + }; + struct{ + real32 v[2]; + }; + }; +}; + +struct Vec3{ + union{ + struct{ + real32 x, y, z; + }; + struct{ + real32 r, g, b; + }; + struct{ + Vec2 xy; + real32 _z; + }; + struct{ + real32 _x; + Vec2 yz; + }; + struct{ + real32 v[3]; + }; + }; +}; + +struct Vec4{ + union{ + struct{ + real32 r, g, b, a; + }; + + struct{ + real32 h, s, l, __a; + }; + struct{ + real32 x, y, z, w; + }; + struct{ + Vec3 rgb; + real32 _a; + }; + struct{ + Vec3 xyz; + real32 _w; + }; + struct{ + real32 _x; + Vec3 yzw; + }; + struct{ + real32 v[4]; + }; + }; +}; + +inline internal Vec2 +V2(real32 x, real32 y){ + Vec2 result; + result.x = x; + result.y = y; + return result; +} + +inline internal Vec3 +V3(real32 x, real32 y, real32 z){ + Vec3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +inline internal Vec4 +V4(real32 x, real32 y, real32 z, real32 w){ + Vec4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +inline internal Vec2 +operator+(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + return result; +} + +inline internal Vec3 +operator+(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + return result; +} + +inline internal Vec4 +operator+(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + return result; +} + +inline internal Vec2 +operator-(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + return result; +} + +inline internal Vec3 +operator-(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + return result; +} + +inline internal Vec4 +operator-(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + return result; +} + +inline internal Vec2 +operator*(Vec2 a, real32 k){ + Vec2 result; + result.x = a.x * k; + result.y = a.y * k; + return result; +} + +inline internal Vec3 +operator*(Vec3 a, real32 k){ + Vec3 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + return result; +} + +inline internal Vec4 +operator*(Vec4 a, real32 k){ + Vec4 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + result.w = a.w * k; + return result; +} + +inline internal Vec2 +operator*(real32 k, Vec2 a){ + Vec2 result; + result.x = a.x * k; + result.y = a.y * k; + return result; +} + +inline internal Vec3 +operator*(real32 k, Vec3 a){ + Vec3 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + return result; +} + +inline internal Vec4 +operator*(real32 k, Vec4 a){ + Vec4 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + result.w = a.w * k; + return result; +} + +inline internal Vec2& +operator+=(Vec2 &a, Vec2 b){ + a = (a + b); + return a; +} + +inline internal Vec3& +operator+=(Vec3 &a, Vec3 b){ + a = (a + b); + return a; +} + +inline internal Vec4& +operator+=(Vec4 &a, Vec4 b){ + a = (a + b); + return a; +} + +inline internal Vec2& +operator-=(Vec2 &a, Vec2 b){ + a = (a - b); + return a; +} + +inline internal Vec3& +operator-=(Vec3 &a, Vec3 b){ + a = (a - b); + return a; +} + +inline internal Vec4& +operator-=(Vec4 &a, Vec4 b){ + a = (a - b); + return a; +} + +inline internal Vec2& +operator*=(Vec2 &a, real32 k){ + a = (a * k); + return a; +} + +inline internal Vec3& +operator*=(Vec3 &a, real32 k){ + a = (a * k); + return a; +} + +inline internal Vec4& +operator*=(Vec4 &a, real32 k){ + a = (a * k); + return a; +} + +inline internal real32 +dot(Vec2 a, Vec2 b){ + real32 result; + result = a.x*b.x + a.y*b.y; + return result; +} + +inline internal real32 +dot(Vec3 a, Vec3 b){ + real32 result; + result = a.x*b.x + a.y*b.y + a.z*b.z; + return result; +} + +inline internal real32 +dot(Vec4 a, Vec4 b){ + real32 result; + result = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w; + return result; +} + +inline internal Vec3 +cross(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.y*b.z - b.y*a.z; + result.y = a.z*b.x - b.z*a.x; + result.z = a.x*b.y - b.x*a.y; + return result; +} + +inline internal Vec2 +hadamard(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + return result; +} + +inline internal Vec3 +hadamard(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + result.z = a.z*b.z; + return result; +} + +inline internal Vec4 +hadamard(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + result.z = a.z*b.z; + result.w = a.w*b.w; + return result; +} + +inline internal Vec2 +perp(Vec2 v){ + Vec2 result; + result.x = -v.y; + result.y = v.x; + return result; +} + +inline Vec2 +polar_to_cartesian(real32 theta_degrees, real32 length){ + Vec2 result; + result.x = COS(theta_degrees)*length; + result.y = SIN(theta_degrees)*length; + return result; +} + +inline Vec2 +rotate(Vec2 v, real32 theta_degrees){ + Vec2 result; + real32 c, s; + c = COS(theta_degrees); + s = SIN(theta_degrees); + result.x = v.x*c - v.y*s; + result.y = v.x*s + v.y*c; + return result; +} + +/* + * Coordinates + */ + +struct Matrix2{ + Vec2 x_axis; + Vec2 y_axis; +}; + +internal Matrix2 +invert(Vec2 x_axis, Vec2 y_axis){ + Matrix2 result = {}; + real32 det = 1.f / (x_axis.x*y_axis.y - x_axis.y*y_axis.x); + result.x_axis.x = y_axis.y*det; + result.y_axis.x = -y_axis.x*det; + result.x_axis.y = -x_axis.y*det; + result.y_axis.y = x_axis.x*det; + return result; +} + +internal Matrix2 +invert(Matrix2 m){ + Matrix2 result = {}; + real32 det = 1.f / (m.x_axis.x*m.y_axis.y - m.x_axis.y*m.y_axis.x); + result.x_axis.x = m.y_axis.y*det; + result.y_axis.x = -m.y_axis.x*det; + result.x_axis.y = -m.x_axis.y*det; + result.y_axis.y = m.x_axis.x*det; + return result; +} + +/* + * Lerps, Clamps, Thresholds, Etc + */ + +inline real32 +lerp(real32 a, real32 t, real32 b){ + return a + (b-a)*t; +} + +inline Vec2 +lerp(Vec2 a, real32 t, Vec2 b){ + return a + (b-a)*t; +} + +inline Vec3 +lerp(Vec3 a, real32 t, Vec3 b){ + return a + (b-a)*t; +} + +inline Vec4 +lerp(Vec4 a, real32 t, Vec4 b){ + return a + (b-a)*t; +} + +inline real32 +unlerp(real32 a, real32 x, real32 b){ + return (x - a) / (b - a); +} + +inline real32 +clamp(real32 a, real32 n, real32 z){ + return (n<a)?(a):((n>z)?(z):n); +} + +/* + * Color + */ + +// TODO(allen): Convert colors to Vec4 +inline internal u32 +color_blend(u32 a, real32 t, u32 b){ + union{ + u8 byte[4]; + u32 comp; + } A, B, R; + + A.comp = a; + B.comp = b; + + R.byte[0] = (u8)lerp(A.byte[0], t, B.byte[0]); + R.byte[1] = (u8)lerp(A.byte[1], t, B.byte[1]); + R.byte[2] = (u8)lerp(A.byte[2], t, B.byte[2]); + R.byte[3] = (u8)lerp(A.byte[3], t, B.byte[3]); + + return R.comp; +} + +internal Vec3 +unpack_color3(u32 color){ + Vec3 result; + result.r = ((color >> 16) & 0xFF) / 255.f; + result.g = ((color >> 8) & 0xFF) / 255.f; + result.b = ((color >> 0) & 0xFF) / 255.f; + return result; +} + +internal Vec4 +unpack_color4(u32 color){ + Vec4 result; + result.a = ((color >> 24) & 0xFF) / 255.f; + result.r = ((color >> 16) & 0xFF) / 255.f; + result.g = ((color >> 8) & 0xFF) / 255.f; + result.b = ((color >> 0) & 0xFF) / 255.f; + return result; +} + +internal u32 +pack_color4(Vec4 color){ + u32 result = + ((u8)(color.a * 255) << 24) | + ((u8)(color.r * 255) << 16) | + ((u8)(color.g * 255) << 8) | + ((u8)(color.b * 255) << 0); + return result; +} + +internal Vec4 +rgba_to_hsla(Vec4 rgba){ + Vec4 hsla = {}; + real32 max, min, delta; + i32 maxc; + hsla.a = rgba.a; + max = rgba.r; min = rgba.r; + maxc = 0; + if (rgba.r < rgba.g){ + max = rgba.g; + maxc = 1; + } + if (rgba.b > max){ + max = rgba.b; + maxc = 2; + } + if (rgba.r > rgba.g){ + min = rgba.g; + } + if (rgba.b < min){ + min = rgba.b; + } + delta = max - min; + + hsla.z = (max + min) * .5f; + if (delta == 0){ + hsla.x = 0.f; + hsla.y = 0.f; + } + else{ + switch (maxc){ + case 0: + { + hsla.x = (rgba.g - rgba.b) / delta; + hsla.x += (rgba.g < rgba.b) * 6.f; + }break; + + case 1: + { + hsla.x = (rgba.b - rgba.r) / delta; + hsla.x += 2.f; + }break; + + case 2: + { + hsla.x = (rgba.r - rgba.g) / delta; + hsla.x += 4.f; + }break; + } + hsla.x *= (1/6.f); // * 60 / 360 + hsla.y = delta / (1.f - ABS(2.f*hsla.z - 1.f)); + } + + return hsla; +} + +internal Vec4 +hsla_to_rgba(Vec4 hsla){ + if (hsla.h >= 1.f) hsla.h = 0.f; + Vec4 rgba = {}; + real32 C, X, m; + i32 H; + rgba.a = hsla.a; + C = (1.f - ABS(2*hsla.z - 1.f)) * hsla.y; + X = C * (1.f-ABS(MOD(hsla.x*6.f, 2)-1.f)); + m = hsla.z - C*.5f; + H = FLOOR32(hsla.x * 6.f); + switch (H){ + case 0: + rgba.r = C; rgba.g = X; rgba.b = 0; + break; + + case 1: + rgba.r = X; rgba.g = C; rgba.b = 0; + break; + + case 2: + rgba.r = 0; rgba.g = C; rgba.b = X; + break; + + case 3: + rgba.r = 0; rgba.g = X; rgba.b = C; + break; + + case 4: + rgba.r = X; rgba.g = 0; rgba.b = C; + break; + + case 5: + rgba.r = C; rgba.g = 0; rgba.b = X; + break; + } + rgba.r += m; + rgba.g += m; + rgba.b += m; + return rgba; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_mem.cpp b/test_data/lots_of_files/4ed_mem.cpp new file mode 100644 index 0000000..84120e7 --- /dev/null +++ b/test_data/lots_of_files/4ed_mem.cpp @@ -0,0 +1,256 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 13.11.2015 + * + * Memory utils for 4coder + * + */ + +// TOP + +struct Partition{ + u8 *base; + i32 pos, max; +}; + +struct Temp_Memory{ + void *handle; + int pos; +}; + +enum Memory_Bubble_Flag{ + MEM_BUBBLE_USED = 0x1, + MEM_BUBBLE_DEBUG = 0xD3000000, + MEM_BUBBLE_SYS_DEBUG = 0x5D000000, + MEM_BUBBLE_DEBUG_MASK = 0xFF000000 +}; + +struct Bubble{ + Bubble *prev; + Bubble *next; + u32 flags; + i32 size; + u32 type; + u32 _unused_; +}; + +struct General_Memory{ + Bubble sentinel; +}; + +struct Mem_Options{ + Partition part; + General_Memory general; +}; + +inline Partition +partition_open(void *memory, i32 size){ + Partition partition; + partition.base = (u8*)memory; + partition.pos = 0; + partition.max = size; + return partition; +} + +inline void* +partition_allocate(Partition *data, i32 size){ + void *ret = 0; + if (size > 0 && data->pos + size <= data->max){ + ret = data->base + data->pos; + data->pos += size; + } + return ret; +} + +inline void +partition_align(Partition *data, u32 boundary){ + --boundary; + data->pos = (data->pos + boundary) & (~boundary); +} + +inline void* +partition_current(Partition *data){ + return data->base + data->pos; +} + +inline i32 +partition_remaining(Partition *data){ + return data->max - data->pos; +} + +inline Partition +partition_sub_part(Partition *data, i32 size){ + Partition result = {}; + void *d = partition_allocate(data, size); + if (d) result = partition_open(d, size); + return result; +} + +#define push_struct(part, T) (T*)partition_allocate(part, sizeof(T)) +#define push_array(part, T, size) (T*)partition_allocate(part, sizeof(T)*(size)) +#define push_block(part, size) partition_allocate(part, size) + +inline void +insert_bubble(Bubble *prev, Bubble *bubble){ + bubble->prev = prev; + bubble->next = prev->next; + bubble->prev->next = bubble; + bubble->next->prev = bubble; +} + +inline void +remove_bubble(Bubble *bubble){ + bubble->prev->next = bubble->next; + bubble->next->prev = bubble->prev; +} + +#if FRED_INTERNAL +#define MEM_BUBBLE_FLAG_INIT MEM_BUBBLE_DEBUG +#else +#define MEM_BUBBLE_FLAG_INIT 0 +#endif + +internal void +general_memory_open(General_Memory *general, void *memory, i32 size){ + general->sentinel.prev = &general->sentinel; + general->sentinel.next = &general->sentinel; + general->sentinel.flags = MEM_BUBBLE_USED; + general->sentinel.size = 0; + + Bubble *first = (Bubble*)memory; + first->flags = (u32)MEM_BUBBLE_FLAG_INIT; + first->size = size - sizeof(Bubble); + insert_bubble(&general->sentinel, first); +} + +internal void +general_memory_check(General_Memory *general){ + Bubble *sentinel = &general->sentinel; + for (Bubble *bubble = sentinel->next; + bubble != sentinel; + bubble = bubble->next){ + Assert(bubble); + + Bubble *next = bubble->next; + Assert(bubble == next->prev); + if (next != sentinel){ + Assert(bubble->next > bubble); + Assert(bubble > bubble->prev); + + char *end_ptr = (char*)(bubble + 1) + bubble->size; + char *next_ptr = (char*)next; + AllowLocal(end_ptr); + AllowLocal(next_ptr); + Assert(end_ptr == next_ptr); + } + } +} + +#define BUBBLE_MIN_SIZE 1024 + +internal void +general_memory_attempt_split(Bubble *bubble, i32 wanted_size){ + i32 remaining_size = bubble->size - wanted_size; + if (remaining_size >= BUBBLE_MIN_SIZE){ + bubble->size = wanted_size; + Bubble *new_bubble = (Bubble*)((u8*)(bubble + 1) + wanted_size); + new_bubble->flags = (u32)MEM_BUBBLE_FLAG_INIT; + new_bubble->size = remaining_size - sizeof(Bubble); + insert_bubble(bubble, new_bubble); + } +} + +internal void* +general_memory_allocate(General_Memory *general, i32 size, u32 type = 0){ + void *result = 0; + for (Bubble *bubble = general->sentinel.next; + bubble != &general->sentinel; + bubble = bubble->next){ + if (!(bubble->flags & MEM_BUBBLE_USED)){ + if (bubble->size >= size){ + result = bubble + 1; + bubble->flags |= MEM_BUBBLE_USED; + bubble->type = type; + general_memory_attempt_split(bubble, size); + break; + } + } + } + return result; +} + +inline void +general_memory_do_merge(Bubble *left, Bubble *right){ + Assert(left->next == right); + Assert(right->prev == left); + left->size += sizeof(Bubble) + right->size; + remove_bubble(right); +} + +inline void +general_memory_attempt_merge(Bubble *left, Bubble *right){ + if (!(left->flags & MEM_BUBBLE_USED) && + !(right->flags & MEM_BUBBLE_USED)){ + general_memory_do_merge(left, right); + } +} + +internal void +general_memory_free(General_Memory *general, void *memory){ + Bubble *bubble = ((Bubble*)memory) - 1; + Assert((!FRED_INTERNAL) || (bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG); + bubble->flags &= ~MEM_BUBBLE_USED; + bubble->type = 0; + Bubble *prev, *next; + prev = bubble->prev; + next = bubble->next; + general_memory_attempt_merge(bubble, next); + general_memory_attempt_merge(prev, bubble); +} + +internal void* +general_memory_reallocate(General_Memory *general, void *old, i32 old_size, i32 size, u32 type = 0){ + void *result = old; + Bubble *bubble = ((Bubble*)old) - 1; + bubble->type = type; + Assert((!FRED_INTERNAL) || (bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG); + i32 additional_space = size - bubble->size; + if (additional_space > 0){ + Bubble *next = bubble->next; + if (!(next->flags & MEM_BUBBLE_USED) && + next->size + sizeof(Bubble) >= additional_space){ + general_memory_do_merge(bubble, next); + general_memory_attempt_split(bubble, size); + } + else{ + result = general_memory_allocate(general, size, type); + if (old_size) memcpy(result, old, old_size); + general_memory_free(general, old); + } + } + return result; +} + +inline void* +general_memory_reallocate_nocopy(General_Memory *general, void *old, i32 size, u32 type = 0){ + return general_memory_reallocate(general, old, 0, size, type); +} + +internal Temp_Memory +begin_temp_memory(Partition *data){ + Temp_Memory result; + result.handle = data; + result.pos = data->pos; + return result; +} + +internal void +end_temp_memory(Temp_Memory temp){ + ((Partition*)temp.handle)->pos = temp.pos; +} + +#define reset_temp_memory end_temp_memory + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_meta.h b/test_data/lots_of_files/4ed_meta.h new file mode 100644 index 0000000..9793924 --- /dev/null +++ b/test_data/lots_of_files/4ed_meta.h @@ -0,0 +1,200 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.12.2014 + * + * Meta setup for project codename "4ed" + * + */ + +#ifndef FRED_META_H +#define FRED_META_H + +#include <string.h> +#include <stdint.h> + +typedef uint8_t u8; +typedef uint64_t u64; +typedef uint32_t u32; +typedef uint16_t u16; + +typedef int8_t i8; +typedef int64_t i64; +typedef int32_t i32; +typedef int16_t i16; + +typedef i32 bool32; +typedef i8 bool8; +typedef i32 b32; +typedef i8 b8; + +typedef uint8_t byte; + +typedef float real32; +typedef double real64; +typedef float f32; +typedef double f64; + +struct Data{ + byte *data; + i32 size; +}; + +#define external extern "C" +#define internal static +#define globalvar static +#define persist static + +#define globalconst static const + +inline i32 +raw_ptr_dif(void *a, void *b) { return (i32)((u8*)a - (u8*)b); } + +#define COMP_ID_(a,b,c,d) (d << 24) | (c << 16) | (b << 8) | a +#define COMPOSE_ID(a,b,c,d) (COMP_ID_((a),(b),(c),(d))) + +#define S(X) #X +#define S_(X) S(X) +#define S__LINE__ S_(__LINE__) + +#if FRED_PRINT_DEBUG == 1 +internal void +_OutDbgStr(u8*); +# include <stdio.h> +# if FRED_PRINT_DEBUG_FILE_LINE +# define FredDbg(con, size, ...) {_OutDbgStr((u8*)("FILE:"__FILE__"LINE:"S__LINE__"\n")); char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);} +# else +# define FredDbg(con, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);} +# endif +#elif FRED_PRINT_DEBUG == 2 +# include <stdio.h> +# if FRED_PRINT_DEBUG_FILE_LINE +# define FredDbg(con, size, ...) {fprintf((con)->log, ("FILE:"__FILE__"LINE:"S__LINE__"\n")); fprintf(__VA_ARGS__);} +# else +# define FredDbg(con, size, ...) {fprintf((con)->log, __VA_ARGS__);} +# endif +#else +# define FredDbg(con, size, ...) +#endif + +#if FRED_INTERNAL && FRED_FULL_ERRORS +# include <stdio.h> +# define FatalErrorFormat(alt, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); FatalError(msg);} +#else +# define FatalErrorFormat(alt, size, ...) {FatalError(alt);} +#endif + +#if FRED_SLOW +# define Assert(c) assert(c) +#else +# define Assert(c) +#endif + +#define TentativeAssert(c) Assert(c) + +#define FatalError(message) system_fatal_error((u8*)message) + +#define AllowLocal(name) (void)name +#define ArrayCount(array) (sizeof(array)/sizeof(array[0])) +#define OffsetOfStruct(S,c) ((i64)(& ((S*)0)->c )) +#define OffsetOfPtr(s,c) ((i64)((char*)(&(s)->c) - (char*)(s))) + +#define Swap(a,b) {auto t = a; a = b; b = t;} + +#ifndef literal +#define literal(s) s, (sizeof(s)-1) +#endif + +#define Min(a,b) (((a)<(b))?(a):(b)) +#define Max(a,b) (((a)>(b))?(a):(b)) + +#define TMax(t,v) globalconst t max_##t = v +TMax(u8, 255); +TMax(u16, 65535); +TMax(u32, 4294967295); +TMax(u64, 18446744073709551615U); + +TMax(i8, 127); +TMax(i16, 32767); +TMax(i32, 2147483647); +TMax(i64, 9223372036854775807); +#undef TMax + +#define TMin(t) globalconst t min_##t = 0 +TMin(u8); +TMin(u16); +TMin(u32); +TMin(u64); +#undef TMin + +#define TMin(t,v) globalconst t min_##t = ((t)v) +TMin(i8, -0xF0); +TMin(i16, -0xF000); +TMin(i32, -0xF00000); +TMin(i64, -0xF0000000LL); +#undef TMin + +internal i32 +LargeRoundUp(i32 x, i32 granularity){ + i32 original_x = x; + x /= granularity; + x *= granularity; + if (x < original_x){ + x += granularity; + } + return x; +} + +#define Bit_0 (1 << 0) +#define Bit_1 (1 << 1) +#define Bit_2 (1 << 2) +#define Bit_3 (1 << 3) +#define Bit_4 (1 << 4) +#define Bit_5 (1 << 5) +#define Bit_6 (1 << 6) +#define Bit_7 (1 << 7) + +#define Bit_8 (1 << 8) +#define Bit_9 (1 << 9) +#define Bit_10 (1 << 10) +#define Bit_11 (1 << 11) +#define Bit_12 (1 << 12) +#define Bit_13 (1 << 13) +#define Bit_14 (1 << 14) +#define Bit_15 (1 << 15) + +#define Bit_16 (1 << 16) +#define Bit_17 (1 << 17) +#define Bit_18 (1 << 18) +#define Bit_19 (1 << 19) +#define Bit_20 (1 << 20) +#define Bit_21 (1 << 21) +#define Bit_22 (1 << 22) +#define Bit_23 (1 << 23) + +#define Bit_24 (1 << 24) +#define Bit_25 (1 << 25) +#define Bit_26 (1 << 26) +#define Bit_27 (1 << 27) +#define Bit_28 (1 << 28) +#define Bit_29 (1 << 29) +#define Bit_30 (1 << 30) +#define Bit_31 (1 << 31) + +#define Byte_0 (0xFFU) +#define Byte_1 (0xFFU << 8) +#define Byte_2 (0xFFU << 16) +#define Byte_3 (0xFFU << 24) +#define Byte_4 (0xFFU << 32) +#define Byte_5 (0xFFU << 40) +#define Byte_6 (0xFFU << 48) +#define Byte_7 (0xFFU << 56) + +#define bytes(n) (n) +#define Kbytes(n) ((n) << 10) +#define Mbytes(n) ((n) << 20) +#define Gbytes(n) (((u64)n) << 30) +#define Tbytes(n) (((u64)n) << 40) + +#endif + diff --git a/test_data/lots_of_files/4ed_metagen.cpp b/test_data/lots_of_files/4ed_metagen.cpp new file mode 100644 index 0000000..7128de5 --- /dev/null +++ b/test_data/lots_of_files/4ed_metagen.cpp @@ -0,0 +1,462 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 25.02.2016 + * + * File editing view for 4coder + * + */ + +// TOP + +#define FCPP_STRING_IMPLEMENTATION +#include "4coder_string.h" + +struct Struct_Field{ + char *type; + char *name; +}; + +void to_lower(char *src, char *dst){ + char *c, ch; + for (c = src; *c != 0; ++c){ + ch = char_to_lower(*c); + *dst++ = ch; + } + *dst = 0; +} + +void to_upper(char *src, char *dst){ + char *c, ch; + for (c = src; *c != 0; ++c){ + ch = char_to_upper(*c); + *dst++ = ch; + } + *dst = 0; +} + +void to_camel(char *src, char *dst){ + char *c, ch; + int is_first = 1; + for (c = src; *c != 0; ++c){ + ch = *c; + if (char_is_alpha_numeric_true(ch)){ + if (is_first){ + is_first = 0; + ch = char_to_upper(ch); + } + else{ + ch = char_to_lower(ch); + } + } + else{ + is_first = 1; + } + *dst++ = ch; + } + *dst = 0; +} + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +void struct_begin(FILE *file, char *name){ + fprintf(file, "struct %s{\n", name); +} + +void struct_fields(FILE *file, Struct_Field *fields, int count){ + int i; + for (i = 0; i < count; ++i){ + fprintf(file, " %s %s;\n", fields[i].type, fields[i].name); + } +} + +void struct_end(FILE *file){ + fprintf(file, "};\n\n"); +} + + +void enum_begin(FILE *file, char *name){ + fprintf(file, "enum %s{\n", name); +} + + +char *keys_that_need_codes[] = { + "back", + "up", + "down", + "left", + "right", + "del", + "insert", + "home", + "end", + "page_up", + "page_down", + "esc", + + "f1", + "f2", + "f3", + "f4", + "f5", + "f6", + "f7", + "f8", + + "f9", + "f10", + "f11", + "f12", + "f13", + "f14", + "f15", + "f16", +}; + +char* generate_keycode_enum(){ + FILE *file; + char *filename = "4coder_keycodes.h"; + int i, count; + unsigned char code = 1; + + file = fopen(filename, "wb"); + fprintf(file, "enum Key_Code{\n"); + count = ArrayCount(keys_that_need_codes); + for (i = 0; i < count;){ + if (strcmp(keys_that_need_codes[i], "f1") == 0 && code < 0x7F){ + code = 0x7F; + } + switch (code){ + case '\n': code++; break; + case '\t': code++; break; + case 0x20: code = 0x7F; break; + default: + fprintf(file, " key_%s = %d,\n", keys_that_need_codes[i++], code++); + break; + } + } + fprintf(file, "};\n"); + fclose(file); + return(filename); +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +char daction_enum_name[] = "Action_Type"; +char *daction_enum[] = { + "OPEN", + "OPEN_BACKGROUND", + "SET_LINE", + "SAVE_AS", + "SAVE", + "NEW", + "SWITCH", + "TRY_KILL", + "KILL", + "TOUCH_FILE", +}; + +char str_alloc_copy[] = +"internal String\n" +"str_alloc_copy(General_Memory *general, String str){\n" +" String result;\n" +" result.memory_size = str.memory_size + 1;\n" +" result.size = str.size;\n" +" result.str = (char*)general_memory_allocate(general, result.memory_size, 0);\n" +" memcpy(result.str, str.str, str.size);\n" +" result.str[result.size] = 0;\n" +" return(result);" +"}\n\n"; + +char daction_name[] = "Delayed_Action"; +Struct_Field daction_fields[] = { + {"Action_Type", "type"}, +}; +Struct_Field daction_fields_primary[] = { + {"String", "string"}, + {"Panel*", "panel"}, + {"Editing_File*", "file"}, + {"i32", "integer"}, +}; +enum Daction_Field_Handle{ + dfph_null, + dfph_string, + dfph_panel, + dfph_file, + dfph_integer, +}; +Daction_Field_Handle dact_param_sets[] = { + dfph_string, dfph_null, + dfph_panel, dfph_null, + dfph_file, dfph_null, + dfph_file, dfph_panel, dfph_null, + dfph_string, dfph_panel, dfph_null, + dfph_string, dfph_file, dfph_null, + dfph_panel, dfph_integer, dfph_null, +}; + +char delay_name[] = "Delay"; +Struct_Field delay_fields[] = { + {"General_Memory*", "general"}, + {"Delayed_Action*", "acts"}, + {"i32", "count"}, + {"i32", "max"}, +}; + +char delayed_action_function_top[] = +"inline Delayed_Action*\n" +"delayed_action_(Delay *delay, Action_Type type"; + +char delayed_action_function_bottom[] = +"){\n" +" Delayed_Action *result;\n" +" if (delay->count == delay->max){\n" +" delay->max *= 2;\n" +" delay->acts = (Delayed_Action*)general_memory_reallocate(" +"delay->general, delay->acts, delay->count*sizeof(Delayed_Action), delay->max*sizeof(Delayed_Action), 0);\n" +" }\n" +" result = delay->acts + delay->count++;\n" +" *result = {};\n" +" result->type = type;\n" +" return(result);\n" +"}\n\n"; + +char delayed_action_special_param[] = ", %s %s"; + +char delayed_action_specialized_middle[] = +"){\n" +" Delayed_Action *result;\n" +" result = delayed_action_(delay, type);\n"; + +char delayed_action_special_line[] = +" result->%s = %s;\n"; + +char delayed_action_special_string_line[] = +" result->%s = str_alloc_copy(delay->general, %s);\n"; + +char delayed_action_specialized_bottom[] = +" return(result);\n" +"}\n\n"; + +char delayed_action_macro[] = +"#define delayed_%s(delay, ...) delayed_action_(delay, DACT_%s, __VA_ARGS__)\n"; + +char delayed_action_repush_function[] = +"inline Delayed_Action*\n" +"delayed_action_repush(Delay *delay, Delayed_Action *act){\n" +" Delayed_Action *new_act = delayed_action_(delay, (Action_Type)0);\n" +" *new_act = *act;\n" +" if (act->string.str){\n" +" new_act->string = str_alloc_copy(delay->general, act->string);\n" +" }\n" +" return(new_act);\n" +"}\n\n"; + +char* generate_delayed_action(){ + FILE *file; + char *filename = "4ed_delay.cpp"; + char scratch[256]; + int i,j; + + file = fopen(filename, "wb"); + + fprintf(file, "enum %s{\n", daction_enum_name); + for (i = 0; i < ArrayCount(daction_enum); ++i){ + fprintf(file, " DACT_%s,\n", daction_enum[i]); + } + fprintf(file, "};\n\n"); + + struct_begin(file, daction_name); + struct_fields(file, daction_fields, ArrayCount(daction_fields)); + struct_fields(file, daction_fields_primary, ArrayCount(daction_fields_primary)); + struct_end(file); + + struct_begin(file, delay_name); + struct_fields(file, delay_fields, ArrayCount(delay_fields)); + struct_end(file); + + fprintf(file, "%s", str_alloc_copy); + fprintf(file, "%s%s", delayed_action_function_top, delayed_action_function_bottom); + + for (i = 0; i < ArrayCount(dact_param_sets); ++i){ + j = i; + fprintf(file, "%s", delayed_action_function_top); + for (; dact_param_sets[i] != dfph_null; ++i){ + Struct_Field field = daction_fields_primary[dact_param_sets[i] - 1]; + fprintf(file, delayed_action_special_param, field.type, field.name); + } + fprintf(file, "%s", delayed_action_specialized_middle); + for (; dact_param_sets[j] != dfph_null; ++j){ + int handle = (int)(dact_param_sets[j]); + Struct_Field field = daction_fields_primary[handle - 1]; + if (handle == dfph_string){ + fprintf(file, delayed_action_special_string_line, field.name, field.name); + } + else{ + fprintf(file, delayed_action_special_line, field.name, field.name); + } + } + fprintf(file, "%s", delayed_action_specialized_bottom); + } + + fprintf(file, "%s", delayed_action_repush_function); + + for (i = 0; i < ArrayCount(daction_enum); ++i){ + to_lower(daction_enum[i], scratch); + fprintf(file, delayed_action_macro, scratch, daction_enum[i]); + } + + return(filename); +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +char* bar_style_fields[] = { + "bar", + "bar_active", + "base", + "pop1", + "pop2", +}; + +char* main_style_fields[] = { + "back", + "margin", + "margin_hover", + "margin_active", + "cursor", + "at_cursor", + "highlight", + "at_highlight", + "mark", + "default", + "comment", + "keyword", + "str_constant", + "char_constant", + "int_constant", + "float_constant", + "bool_constant", + "preproc", + "include", + "special_character", + "highlight_junk", + "highlight_white", + "paste", + "undo", + "next_undo", +}; + +static char* +make_style_tag(char *tag){ + char *str; + int len; + + len = (int)strlen(tag); + str = (char*)malloc(len + 1); + to_camel(tag, str); + str[len] = 0; + + return(str); +} + +char style_index_function_start[] = +"inline u32*\n" +"style_index_by_tag(Style_Main_Data *s, u32 tag){\n" +" u32 *result = 0;\n" +" switch (tag){\n"; + +char style_index_function_end[] = +" }\n" +" return(result);\n" +"}\n\n"; + +char style_case[] = " case Stag_%s: result = &s->%s_color; break;\n"; +char style_info_case[] = " case Stag_%s: result = &s->file_info_style.%s_color; break;\n"; + +char* generate_style(){ + char *filename = "4coder_style.h & 4ed_style.h"; + char filename_4coder[] = "4coder_style.h"; + char filename_4ed[] = "4ed_style.h"; + FILE *file; + char *tag; + int count, i; + + file = fopen(filename_4coder, "wb"); + enum_begin(file, "Style_Tag"); + { + count = ArrayCount(bar_style_fields); + for (i = 0; i < count; ++i){ + tag = make_style_tag(bar_style_fields[i]); + fprintf(file, "Stag_%s,\n", tag); + free(tag); + } + + count = ArrayCount(main_style_fields); + for (i = 0; i < count; ++i){ + tag = make_style_tag(main_style_fields[i]); + fprintf(file, "Stag_%s,\n", tag); + free(tag); + } + } + struct_end(file); + fclose(file); + + file = fopen(filename_4ed, "wb"); + struct_begin(file, "Interactive_Style"); + { + count = ArrayCount(bar_style_fields); + for (i = 0; i < count; ++i){ + fprintf(file, "u32 %s_color;\n", bar_style_fields[i]); + } + } + struct_end(file); + + struct_begin(file, "Style_Main_Data"); + { + count = ArrayCount(main_style_fields); + for (i = 0; i < count; ++i){ + fprintf(file, "u32 %s_color;\n", main_style_fields[i]); + } + fprintf(file, "Interactive_Style file_info_style;\n"); + } + struct_end(file); + + { + fprintf(file, "%s", style_index_function_start); + count = ArrayCount(bar_style_fields); + for (i = 0; i < count; ++i){ + tag = make_style_tag(bar_style_fields[i]); + fprintf(file, style_info_case, tag, bar_style_fields[i]); + free(tag); + } + + count = ArrayCount(main_style_fields); + for (i = 0; i < count; ++i){ + tag = make_style_tag(main_style_fields[i]); + fprintf(file, style_case, tag, main_style_fields[i]); + free(tag); + } + fprintf(file, "%s", style_index_function_end); + } + + fclose(file); + + return(filename); +} + +int main(){ + char *filename; + + filename = generate_keycode_enum(); + printf("gen success: %s\n", filename); + + filename = generate_delayed_action(); + printf("gen success: %s\n", filename); + + filename = generate_style(); + printf("gen success: %s\n", filename); +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_rendering.cpp b/test_data/lots_of_files/4ed_rendering.cpp new file mode 100644 index 0000000..d4cecd5 --- /dev/null +++ b/test_data/lots_of_files/4ed_rendering.cpp @@ -0,0 +1,508 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.17.2014 + * + * Rendering layer for project codename "4ed" + * + */ + +// TOP + +inline void +draw_set_clip(Render_Target *target, i32_Rect clip_box){ + glScissor(clip_box.x0, + target->height - clip_box.y1, + clip_box.x1 - clip_box.x0, + clip_box.y1 - clip_box.y0); +} + +inline void +draw_bind_texture(Render_Target *target, i32 texid){ + if (target->bound_texture != texid){ + glBindTexture(GL_TEXTURE_2D, texid); + target->bound_texture = texid; + } +} + +inline void +draw_set_color(Render_Target *target, u32 color){ + if (target->color != color){ + target->color = color; + Vec4 c = unpack_color4(color); + glColor4f(c.r, c.g, c.b, c.a); + } +} + +#define PutStruct(s,x) *(s*)(target->push_buffer + target->size) = x; target->size += sizeof(s) + +internal void +draw_push_piece(Render_Target *target, Render_Piece_Combined piece){ + PutStruct(Render_Piece_Header, piece.header); + + switch (piece.header.type){ + case piece_type_rectangle: + case piece_type_outline: + PutStruct(Render_Piece_Rectangle, piece.rectangle); + break; + + case piece_type_gradient: + PutStruct(Render_Piece_Gradient, piece.gradient); + break; + + case piece_type_glyph: + case piece_type_mono_glyph: + PutStruct(Render_Piece_Glyph, piece.glyph); + break; + + case piece_type_mono_glyph_advance: + PutStruct(Render_Piece_Glyph_Advance, piece.glyph_advance); + break; + } + + Assert(target->size <= target->max); +} + +internal void +draw_push_piece_clip(Render_Target *target, i32_Rect clip_box){ + // TODO(allen): optimize out if there are two clip box changes in a row + Render_Piece_Change_Clip clip; + Render_Piece_Header header; + + header.type = piece_type_change_clip; + clip.box = clip_box; + + PutStruct(Render_Piece_Header, header); + PutStruct(Render_Piece_Change_Clip, clip); +} + +internal void +draw_push_clip(Render_Target *target, i32_Rect clip_box){ + Assert(target->clip_top == -1 || + fits_inside(clip_box, target->clip_boxes[target->clip_top])); + Assert(target->clip_top+1 < ArrayCount(target->clip_boxes)); + target->clip_boxes[++target->clip_top] = clip_box; + + draw_push_piece_clip(target, clip_box); +} + +internal void +draw_pop_clip(Render_Target *target){ + i32_Rect clip_box; + Assert(target->clip_top > 0); + --target->clip_top; + clip_box = target->clip_boxes[target->clip_top]; + + draw_push_piece_clip(target, clip_box); +} + +#define ExtractStruct(s) ((s*)cursor); cursor += sizeof(s) + +inline void +private_draw_rectangle(Render_Target *target, f32_Rect rect, u32 color){ + draw_set_color(target, color); + draw_bind_texture(target, 0); + glBegin(GL_QUADS); + { + glVertex2f(rect.x0, rect.y0); + glVertex2f(rect.x0, rect.y1); + glVertex2f(rect.x1, rect.y1); + glVertex2f(rect.x1, rect.y0); + } + glEnd(); +} + +inline void +private_draw_rectangle_outline(Render_Target *target, f32_Rect rect, u32 color){ + f32_Rect r; + r.x0 = rect.x0 + .5f; + r.y0 = rect.y0 + .5f; + r.x1 = rect.x1 - .5f; + r.y1 = rect.y1 - .5f; + + draw_set_color(target, color); + draw_bind_texture(target, 0); + glBegin(GL_LINE_STRIP); + { + glVertex2f(r.x0, r.y0); + glVertex2f(r.x1, r.y0); + glVertex2f(r.x1, r.y1); + glVertex2f(r.x0, r.y1); + glVertex2f(r.x0, r.y0); + } + glEnd(); +} + +inline void +private_draw_gradient(Render_Target *target, f32_Rect rect, + Vec4 color_left, Vec4 color_right){ + Vec4 cl = color_left; + Vec4 cr = color_right; + + draw_bind_texture(target, 0); + glBegin(GL_QUADS); + { + glColor4f(cl.r, cl.g, cl.b, cl.a); + glVertex2f(rect.x0, rect.y0); + glVertex2f(rect.x0, rect.y1); + + glColor4f(cr.r, cr.g, cr.b, cr.a); + glVertex2f(rect.x1, rect.y1); + glVertex2f(rect.x1, rect.y0); + } + glEnd(); +} + +inline void +private_draw_glyph(Render_Target *target, Render_Font *font, + u8 character, f32 x, f32 y, u32 color){ + f32 x_shift, y_shift; + x_shift = 0; + y_shift = (f32)font->ascent; + + x += x_shift; + y += y_shift; + + stbtt_aligned_quad q; + stbtt_GetPackedQuad(font->chardata, font->tex_width, font->tex_height, + character, &x, &y, &q, 0); + + draw_set_color(target, color); + draw_bind_texture(target, font->tex); + glBegin(GL_QUADS); + { + glTexCoord2f(q.s0, q.t1); glVertex2f(q.x0, q.y1); + glTexCoord2f(q.s1, q.t1); glVertex2f(q.x1, q.y1); + glTexCoord2f(q.s1, q.t0); glVertex2f(q.x1, q.y0); + glTexCoord2f(q.s0, q.t0); glVertex2f(q.x0, q.y0); + } + glEnd(); +} + +inline void +private_draw_glyph_mono(Render_Target *target, Render_Font *font, u8 character, + f32 x, f32 y, f32 advance, u32 color){ + f32 x_shift, y_shift; + i32 left = font->chardata[character].x0; + i32 right = font->chardata[character].x1; + i32 width = (right - left); + x_shift = (f32)(advance - width) * .5f - font->chardata[character].xoff; + y_shift = (f32)font->ascent; + + x += x_shift; + y += y_shift; + + stbtt_aligned_quad q; + stbtt_GetPackedQuad(font->chardata, font->tex_width, font->tex_height, + character, &x, &y, &q, 0); + + draw_set_color(target, color); + draw_bind_texture(target, font->tex); + glBegin(GL_QUADS); + { + glTexCoord2f(q.s0, q.t1); glVertex2f(q.x0, q.y1); + glTexCoord2f(q.s1, q.t1); glVertex2f(q.x1, q.y1); + glTexCoord2f(q.s1, q.t0); glVertex2f(q.x1, q.y0); + glTexCoord2f(q.s0, q.t0); glVertex2f(q.x0, q.y0); + } + glEnd(); +} + +inline void +private_draw_glyph_mono(Render_Target *target, Render_Font *font, u8 character, + real32 x, real32 y, u32 color){ + private_draw_glyph_mono(target, font, character, x, y, (f32)font->advance, color); +} + +internal void +launch_rendering(Render_Target *target){ + byte *cursor = target->push_buffer; + byte *cursor_end = cursor + target->size; + + for (; cursor < cursor_end;){ + Render_Piece_Header *header = ExtractStruct(Render_Piece_Header); + + i32 type = header->type; + switch (type){ + case piece_type_rectangle: + { + Render_Piece_Rectangle *rectangle = + ExtractStruct(Render_Piece_Rectangle); + private_draw_rectangle(target, rectangle->rect, rectangle->color); + }break; + + case piece_type_outline: + { + Render_Piece_Rectangle *rectangle = + ExtractStruct(Render_Piece_Rectangle); + private_draw_rectangle_outline(target, rectangle->rect, rectangle->color); + }break; + + case piece_type_gradient: + { + Render_Piece_Gradient *gradient = + ExtractStruct(Render_Piece_Gradient); + private_draw_gradient(target, gradient->rect, + unpack_color4(gradient->left_color), + unpack_color4(gradient->right_color)); + }break; + + case piece_type_glyph: + { + Render_Piece_Glyph *glyph = + ExtractStruct(Render_Piece_Glyph); + + Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font; + if (font) + private_draw_glyph(target, font, glyph->character, + glyph->pos.x, glyph->pos.y, glyph->color); + }break; + + case piece_type_mono_glyph: + { + Render_Piece_Glyph *glyph = + ExtractStruct(Render_Piece_Glyph); + + Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font; + if (font) + private_draw_glyph_mono(target, font, glyph->character, + glyph->pos.x, glyph->pos.y, glyph->color); + }break; + + case piece_type_mono_glyph_advance: + { + Render_Piece_Glyph_Advance *glyph = + ExtractStruct(Render_Piece_Glyph_Advance); + + Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font; + if (font) + private_draw_glyph_mono(target, font, glyph->character, + glyph->pos.x, glyph->pos.y, + glyph->advance, glyph->color); + }break; + + case piece_type_change_clip: + { + Render_Piece_Change_Clip *clip = + ExtractStruct(Render_Piece_Change_Clip); + draw_set_clip(target, clip->box); + }break; + } + } +} + +#undef ExtractStruct + +internal i32 +draw_font_info_load(Partition *partition, + char *filename_untranslated, + i32 pt_size, i32 *height, i32 *advance){ + + char space_[1024]; + String filename = make_fixed_width_string(space_); + b32 translate_success = system_to_binary_path(&filename, filename_untranslated); + if (!translate_success) return 0; + + i32 result = 1; + Data file; + file = system_load_file(filename.str); + + Temp_Memory temp = begin_temp_memory(partition); + stbtt_packedchar *chardata = push_array(partition, stbtt_packedchar, 256); + + i32 oversample = 2; + + i32 tex_width, tex_height; + tex_width = pt_size*128*oversample; + tex_height = pt_size*2*oversample; + void *block = push_block(partition, tex_width * tex_height); + + if (!file.data){ + result = 0; + } + else{ + stbtt_fontinfo font; + if (!stbtt_InitFont(&font, (u8*)file.data, 0)){ + result = 0; + } + else{ + i32 ascent, descent, line_gap; + f32 scale; + + stbtt_GetFontVMetrics(&font, &ascent, &descent, &line_gap); + scale = stbtt_ScaleForPixelHeight(&font, (f32)pt_size); + + f32 scaled_ascent, scaled_descent, scaled_line_gap; + + scaled_ascent = scale*ascent; + scaled_descent = scale*descent; + scaled_line_gap = scale*line_gap; + + i32 font_height = (i32)(scaled_ascent - scaled_descent + scaled_line_gap); + + stbtt_pack_context spc; + if (stbtt_PackBegin(&spc, (u8*)block, tex_width, tex_height, tex_width, 1, partition)){ + stbtt_PackSetOversampling(&spc, oversample, oversample); + if (stbtt_PackFontRange(&spc, (u8*)file.data, 0, + STBTT_POINT_SIZE((f32)pt_size), 0, 128, chardata)){ + // do nothing + } + else{ + result = 0; + } + + stbtt_PackEnd(&spc); + } + else{ + result = 0; + } + + if (result){ + i32 max_advance = 0; + for (u8 code_point = 0; code_point < 128; ++code_point){ + if (stbtt_FindGlyphIndex(&font, code_point) != 0){ + i32 adv = CEIL32(chardata[code_point].xadvance); + if (max_advance < adv){ + max_advance = adv; + } + } + } + + *height = font_height; + *advance = max_advance - 1; + } + } + + system_free_memory(file.data); + } + + end_temp_memory(temp); + + return(result); +} + +internal i32 +draw_font_load(void *base_block, i32 size, + Render_Font *font_out, + char *filename_untranslated, + i32 pt_size, + i32 tab_width){ + + char space_[1024]; + String filename = make_fixed_width_string(space_); + b32 translate_success = system_to_binary_path(&filename, filename_untranslated); + if (!translate_success) return 0; + + i32 result = 1; + Data file; + file = system_load_file(filename.str); + + Partition partition_ = partition_open(base_block, size); + Partition *partition = &partition_; + + stbtt_packedchar *chardata = font_out->chardata; + + i32 oversample = 2; + + i32 tex_width, tex_height; + tex_width = pt_size*128*oversample; + tex_height = pt_size*2*oversample; + void *block = push_block(partition, tex_width * tex_height); + + if (!file.data){ + result = 0; + } + + else{ + stbtt_fontinfo font; + if (!stbtt_InitFont(&font, (u8*)file.data, 0)){ + result = 0; + } + else{ + i32 ascent, descent, line_gap; + f32 scale; + + stbtt_GetFontVMetrics(&font, &ascent, &descent, &line_gap); + scale = stbtt_ScaleForPixelHeight(&font, (f32)pt_size); + + f32 scaled_ascent, scaled_descent, scaled_line_gap; + + scaled_ascent = scale*ascent; + scaled_descent = scale*descent; + scaled_line_gap = scale*line_gap; + + font_out->height = (i32)(scaled_ascent - scaled_descent + scaled_line_gap); + font_out->ascent = (i32)(scaled_ascent); + font_out->descent = (i32)(scaled_descent); + font_out->line_skip = (i32)(scaled_line_gap); + + font_out->tex_width = tex_width; + font_out->tex_height = tex_height; + + stbtt_pack_context spc; + + if (stbtt_PackBegin(&spc, (u8*)block, tex_width, tex_height, tex_width, 1, partition)){ + stbtt_PackSetOversampling(&spc, oversample, oversample); + if (stbtt_PackFontRange(&spc, (u8*)file.data, 0, + STBTT_POINT_SIZE((f32)pt_size), 0, 128, chardata)){ + // do nothing + } + else{ + result = 0; + } + + stbtt_PackEnd(&spc); + } + else{ + result = 0; + } + + if (result){ + GLuint font_tex; + glGenTextures(1, &font_tex); + glBindTexture(GL_TEXTURE_2D, font_tex); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, tex_width, tex_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, block); + + font_out->tex = font_tex; + glBindTexture(GL_TEXTURE_2D, 0); + + font_out->chardata['\r'] = font_out->chardata[' ']; + font_out->chardata['\n'] = font_out->chardata[' ']; + font_out->chardata['\t'] = font_out->chardata[' ']; + font_out->chardata['\t'].xadvance *= tab_width; + + i32 max_advance = 0; + for (u8 code_point = 0; code_point < 128; ++code_point){ + if (stbtt_FindGlyphIndex(&font, code_point) != 0){ + font_out->glyphs[code_point].exists = 1; + i32 advance = CEIL32(font_out->chardata[code_point].xadvance); + if (max_advance < advance) max_advance = advance; + font_out->advance_data[code_point] = font_out->chardata[code_point].xadvance; + } + else if (code_point == '\r' || code_point == '\n' || code_point == '\t'){ + font_out->advance_data[code_point] = font_out->chardata[code_point].xadvance; + } + } + font_out->advance = max_advance - 1; + } + + } + system_free_memory(file.data); + } + + return result; +} + +internal +Release_Font_Sig(draw_release_font){ + glDeleteTextures(1, &font->tex); + font->tex = 0; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_rendering.h b/test_data/lots_of_files/4ed_rendering.h new file mode 100644 index 0000000..b0fbccc --- /dev/null +++ b/test_data/lots_of_files/4ed_rendering.h @@ -0,0 +1,206 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 17.12.2014 + * + * Rendering layer for project codename "4ed" + * + */ + +// TOP + +#ifndef FRED_RENDERING_H +#define FRED_RENDERING_H + +internal void* +part_alloc(int size, void *context){ + Partition *part = (Partition*)context; + void *result = push_block(part, size); + return(result); +} + +internal void +part_free(void *ptr, void *context){ +} + +#define STBTT_malloc part_alloc +#define STBTT_free part_free + +#define STB_TRUETYPE_IMPLEMENTATION +#include "stb_truetype.h" + +struct Glyph_Data{ + b32 exists; +}; + +struct Render_Font{ + char name_[24]; + String name; + b32 loaded; + + Glyph_Data glyphs[256]; + stbtt_packedchar chardata[256]; + float advance_data[256]; + i32 height, ascent, descent, line_skip; + i32 advance; + u32 tex; + i32 tex_width, tex_height; +}; + +enum Render_Piece_Type{ + piece_type_rectangle, + piece_type_outline, + piece_type_gradient, + piece_type_glyph, + piece_type_mono_glyph, + piece_type_mono_glyph_advance, + piece_type_change_clip +}; + +struct Render_Piece_Header{ + i32 type; +}; + +struct Render_Piece_Rectangle{ + f32_Rect rect; + u32 color; +}; + +struct Render_Piece_Gradient{ + f32_Rect rect; + u32 left_color, right_color; +}; + +struct Render_Piece_Glyph{ + Vec2 pos; + u32 color; + i16 font_id; + u8 character; +}; + +struct Render_Piece_Glyph_Advance{ + Vec2 pos; + u32 color; + f32 advance; + i16 font_id; + u8 character; +}; + +struct Render_Piece_Change_Clip{ + i32_Rect box; +}; + +struct Render_Piece_Combined{ + Render_Piece_Header header; + union{ + Render_Piece_Rectangle rectangle; + Render_Piece_Gradient gradient; + Render_Piece_Glyph glyph; + Render_Piece_Glyph_Advance glyph_advance; + }; +}; + +struct Render_Target; + +#define Draw_Push_Clip_Sig(name) void name(Render_Target *target, i32_Rect clip_box) +typedef Draw_Push_Clip_Sig(Draw_Push_Clip); + +#define Draw_Pop_Clip_Sig(name) void name(Render_Target *target) +typedef Draw_Pop_Clip_Sig(Draw_Pop_Clip); + +#define Draw_Push_Piece_Sig(name) void name(Render_Target *target, Render_Piece_Combined piece) +typedef Draw_Push_Piece_Sig(Draw_Push_Piece); + +#define Font_Load_Sig(name) i32 name( \ + Render_Font *font_out, \ + char *filename, \ + i32 pt_size, \ + i32 tab_width) +typedef Font_Load_Sig(Font_Load); + +#define Font_Info_Load_Sig(name) i32 name( \ + Partition *partition, \ + char *filename, \ + i32 pt_size, \ + i32 *height, \ + i32 *advance) +typedef Font_Info_Load_Sig(Font_Info_Load); + +#define Release_Font_Sig(name) void name(Render_Font *font) +typedef Release_Font_Sig(Release_Font); + +struct Font_Table_Entry{ + u32 hash; + String name; + i16 font_id; +}; + +struct Font_Info{ + Render_Font *font; + String filename; + String name; + i32 height, advance; + i32 pt_size; +}; + +struct Font_Slot{ + Font_Slot *next, *prev; + i16 font_id; + u8 padding[14]; +}; + +struct Font_Set{ + Font_Info *info; + Font_Table_Entry *entries; + u32 count, max; + + void *font_block; + Font_Slot free_slots; + Font_Slot used_slots; + + Font_Info_Load *font_info_load; + Font_Load *font_load; + Release_Font *release_font; + + b8 *font_used_flags; + i16 used_this_frame; + i16 live_max; +}; + +struct Render_Target{ + void *handle; + void *context; + i32_Rect clip_boxes[5]; + i32 clip_top; + i32 width, height; + i32 bound_texture; + u32 color; + + // TODO(allen): change this to a Partition + byte *push_buffer; + i32 size, max; + + // TODO(allen): rename this to font_partition + Font_Set font_set; + Partition *partition; + + Draw_Push_Clip *push_clip; + Draw_Pop_Clip *pop_clip; + Draw_Push_Piece *push_piece; +}; + +inline i32_Rect +rect_from_target(Render_Target *target){ + return i32R(0, 0, target->width, target->height); +} + +inline Font_Info* +get_font_info(Font_Set *set, i16 font_id){ + Font_Info *result = set->info + font_id - 1; + return(result); +} + +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_rendering_helper.cpp b/test_data/lots_of_files/4ed_rendering_helper.cpp new file mode 100644 index 0000000..c2c1d75 --- /dev/null +++ b/test_data/lots_of_files/4ed_rendering_helper.cpp @@ -0,0 +1,267 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.17.2014 + * + * Rendering layer for project codename "4ed" + * + */ + +// TOP + +inline void +draw_push_clip(Render_Target *target, i32_Rect clip_box){ + target->push_clip(target, clip_box); +} + +inline void +draw_pop_clip(Render_Target *target){ + target->pop_clip(target); +} + +internal void +begin_render_section(Render_Target *target, System_Functions *system){ + Font_Set *font_set = &target->font_set; + system->acquire_lock(RENDER_LOCK); + font_set->used_this_frame = 0; + memset(font_set->font_used_flags, 0, font_set->max); + target->size = 0; + target->clip_top = -1; + + i32_Rect clip; + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = target->width; + clip.y1 = target->height; + draw_push_clip(target, clip); +} + +internal void +end_render_section(Render_Target *target, System_Functions *system){ + Assert(target->clip_top == 0); + system->release_lock(RENDER_LOCK); +} + +internal void +draw_rectangle(Render_Target *target, i32_Rect rect, u32 color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_rectangle; + piece.rectangle.rect = f32R(rect); + piece.rectangle.color = color; + target->push_piece(target, piece); +} + +internal void +draw_rectangle(Render_Target *target, f32_Rect rect, u32 color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_rectangle; + piece.rectangle.rect = rect; + piece.rectangle.color = color; + target->push_piece(target, piece); +} + +internal void +draw_gradient_2corner_clipped(Render_Target *target, f32_Rect rect, + Vec4 left_color, Vec4 right_color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_gradient; + piece.gradient.rect = rect; + piece.gradient.left_color = pack_color4(left_color); + piece.gradient.right_color = pack_color4(right_color); + target->push_piece(target, piece); +} + +inline void +draw_gradient_2corner_clipped(Render_Target *target, f32 l, f32 t, f32 r, f32 b, + Vec4 color_left, Vec4 color_right){ + draw_gradient_2corner_clipped(target, f32R(l,t,r,b), color_left, color_right); +} + +internal void +draw_rectangle_outline(Render_Target *target, f32_Rect rect, u32 color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_outline; + piece.rectangle.rect = rect; + piece.rectangle.color = color; + target->push_piece(target, piece); +} + +inline void +draw_rectangle_outline(Render_Target *target, i32_Rect rect, u32 color){ + draw_rectangle_outline(target, f32R(rect), color); +} + +internal void +draw_margin(Render_Target *target, i32_Rect outer, i32_Rect inner, u32 color){ + draw_rectangle(target, i32R(outer.x0, outer.y0, outer.x1, inner.y0), color); + draw_rectangle(target, i32R(outer.x0, inner.y1, outer.x1, outer.y1), color); + draw_rectangle(target, i32R(outer.x0, inner.y0, inner.x0, inner.y1), color); + draw_rectangle(target, i32R(inner.x1, inner.y0, outer.x1, inner.y1), color); +} + +inline void +draw_margin(Render_Target *target, i32_Rect outer, i32 width, u32 color){ + i32_Rect inner = get_inner_rect(outer, width); + draw_margin(target, outer, inner, color); +} + +inline internal i32 +font_predict_size(i32 pt_size){ + return pt_size*pt_size*128; +} + +internal void +font_set_tabwidth(Render_Font *font, i32 tab_width){ + font->chardata['\t'].xadvance *= font->chardata[' '].xadvance * tab_width; +} + +internal void +font_draw_glyph_mono(Render_Target *target, i16 font_id, + u8 character, f32 x, f32 y, f32 advance, u32 color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_mono_glyph; + piece.glyph.pos.x = x; + piece.glyph.pos.y = y; + piece.glyph.color = color; + piece.glyph.font_id = font_id; + piece.glyph.character = character; + target->push_piece(target, piece); + font_set_use(target->partition, &target->font_set, font_id); +} + +inline void +font_draw_glyph_mono(Render_Target *target, i16 font_id, + u8 character, f32 x, f32 y, u32 color){ + f32 advance = (f32)get_font_info(&target->font_set, font_id)->advance; + font_draw_glyph_mono(target, font_id, character, x, y, advance, color); +} + +internal void +font_draw_glyph(Render_Target *target, i16 font_id, + u8 character, f32 x, f32 y, u32 color){ + Render_Piece_Combined piece; + piece.header.type = piece_type_glyph; + piece.glyph.pos.x = x; + piece.glyph.pos.y = y; + piece.glyph.color = color; + piece.glyph.font_id = font_id; + piece.glyph.character = character; + target->push_piece(target, piece); + font_set_use(target->partition, &target->font_set, font_id); +} + +inline f32 +font_get_glyph_width(Render_Target *target, i16 font_id, u16 character){ + Render_Font *font = get_font_info(&target->font_set, font_id)->font; + f32 result = 0.f; + if (font) result = font->chardata[character].xadvance; + return (result); +} + +internal f32 +font_string_width(Render_Target *target, i16 font_id, char *str){ + f32 x = 0; + for (i32 i = 0; str[i]; ++i){ + u8 c = str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + x += font_get_glyph_width(target, font_id, c); + } + return x; +} + +internal f32 +font_string_width(Render_Target *target, i16 font_id, String str){ + f32 x = 0; + for (i32 i = 0; i < str.size; ++i){ + u8 c = str.str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + x += font_get_glyph_width(target, font_id, c); + } + return x; +} + +internal i32 +draw_string(Render_Target *target, i16 font_id, + char *str, i32 x_, i32 y, u32 color){ + real32 x = (real32)x_; + for (i32 i = 0; str[i]; ++i){ + u8 c = str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + font_draw_glyph(target, font_id, c, x, (f32)y, color); + x += font_get_glyph_width(target, font_id, c); + } + return CEIL32(x); +} + +internal f32 +draw_string_mono(Render_Target *target, i16 font_id, + char *str, f32 x, f32 y, f32 advance, u32 color){ + for (i32 i = 0; str[i]; ++i){ + u8 c = str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + font_draw_glyph_mono(target, font_id, c, x, y, advance, color); + x += advance; + } + return x; +} + +internal i32 +draw_string(Render_Target *target, i16 font_id, + String str, i32 x_, i32 y, u32 color){ + f32 x = (f32)x_; + for (i32 i = 0; i < str.size; ++i){ + u8 c = str.str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + font_draw_glyph(target, font_id, c, + x, (f32)y, color); + x += font_get_glyph_width(target, font_id, c); + } + return CEIL32(x); +} + +internal f32 +draw_string_mono(Render_Target *target, i16 font_id, + String str, f32 x, f32 y, f32 advance, u32 color){ + for (i32 i = 0; i < str.size; ++i){ + u8 c = str.str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + font_draw_glyph_mono(target, font_id, c, x, y, advance, color); + x += advance; + } + return x; +} + +internal f32 +font_get_max_width(Font_Set *font_set, i16 font_id, char *characters){ + Render_Font *font = get_font_info(font_set, font_id)->font; + f32 cx, x = 0; + if (font){ + stbtt_packedchar *chardata = font->chardata; + for (i32 i = 0; characters[i]; ++i){ + cx = chardata[characters[i]].xadvance; + if (x < cx) x = cx; + } + } + return x; +} + +internal f32 +font_get_string_width(Render_Target *target, i16 font_id, String string){ + f32 result = 0; + for (i32 i = 0; i < string.size; ++i){ + u8 c = string.str[i]; + // TODO(allen): Someday let's not punt on the the unicode rendering + c = c % 128; + font_get_glyph_width(target, font_id, c); + } + return result; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_style.cpp b/test_data/lots_of_files/4ed_style.cpp new file mode 100644 index 0000000..903f8c1 --- /dev/null +++ b/test_data/lots_of_files/4ed_style.cpp @@ -0,0 +1,102 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 28.08.2015 + * + * Styles for 4coder + * + */ + +// TOP + +// TODO(allen): +// Font changing UI should be in the library menu now, it's not tied to the fonts any more +// Get the import export stuff up and running for styles again + +struct Style_Font{ + i16 font_id; + i16 font_changed; +}; + +struct Style{ + char name_[24]; + String name; + Style_Main_Data main; +}; + +internal void +style_copy(Style *dst, Style *src){ + *dst = *src; + dst->name.str = dst->name_; +} + +internal void +style_set_name(Style *style, String name){ + i32 count = ArrayCount(style->name_); + style->name = make_string(style->name_, 0, count - 1); + copy(&style->name, name); + terminate_with_null(&style->name); +} + +struct Style_Library{ + Style styles[64]; + i32 count, max; +}; + +#if 0 +struct Style_File_Format{ + i32 name_size; + char name[24]; + + i32 color_specifier_count; +}; + +internal b32 +style_library_add(Style_Library *library, Style *style){ + b32 result = 0; + i32 count = library->count; + String my_name = style->name; + Style *ostyle = library->styles; + Style *out = 0; + // TODO(allen): hashtable for name lookup? + for (i32 i = 0; i < count; ++i, ++ostyle){ + if (match(my_name, ostyle->name)){ + out = ostyle; + break; + } + } + if (!out && count < library->max){ + out = library->styles + library->count++; + } + if (out){ + style_copy(out, style); + result = 1; + } + return result; +} + +internal Style_File_Format* +style_format_for_file(Font_Set *set, Style *style, Style_File_Format *out){ + out->name_size = style->name.size; + memcpy(out->name, style->name.str, ArrayCount(out->name)); + + Style_Color_Specifier *spec = (Style_Color_Specifier*)(out + 1); + i32 count = 0; + + for (u32 i = 0; i < Stag_Count; ++i){ + u32 *color = style_index_by_tag(style, i); + if (color){ + spec->tag = i; + spec->color = *color; + ++count; + ++spec; + } + } + out->color_specifier_count = count; + + return (Style_File_Format*)spec; +} +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_style.h b/test_data/lots_of_files/4ed_style.h new file mode 100644 index 0000000..0ae1e91 --- /dev/null +++ b/test_data/lots_of_files/4ed_style.h @@ -0,0 +1,75 @@ +struct Interactive_Style{ +u32 bar_color; +u32 bar_active_color; +u32 base_color; +u32 pop1_color; +u32 pop2_color; +}; + +struct Style_Main_Data{ +u32 back_color; +u32 margin_color; +u32 margin_hover_color; +u32 margin_active_color; +u32 cursor_color; +u32 at_cursor_color; +u32 highlight_color; +u32 at_highlight_color; +u32 mark_color; +u32 default_color; +u32 comment_color; +u32 keyword_color; +u32 str_constant_color; +u32 char_constant_color; +u32 int_constant_color; +u32 float_constant_color; +u32 bool_constant_color; +u32 preproc_color; +u32 include_color; +u32 special_character_color; +u32 highlight_junk_color; +u32 highlight_white_color; +u32 paste_color; +u32 undo_color; +u32 next_undo_color; +Interactive_Style file_info_style; +}; + +inline u32* +style_index_by_tag(Style_Main_Data *s, u32 tag){ + u32 *result = 0; + switch (tag){ + case Stag_Bar: result = &s->file_info_style.bar_color; break; + case Stag_Bar_Active: result = &s->file_info_style.bar_active_color; break; + case Stag_Base: result = &s->file_info_style.base_color; break; + case Stag_Pop1: result = &s->file_info_style.pop1_color; break; + case Stag_Pop2: result = &s->file_info_style.pop2_color; break; + case Stag_Back: result = &s->back_color; break; + case Stag_Margin: result = &s->margin_color; break; + case Stag_Margin_Hover: result = &s->margin_hover_color; break; + case Stag_Margin_Active: result = &s->margin_active_color; break; + case Stag_Cursor: result = &s->cursor_color; break; + case Stag_At_Cursor: result = &s->at_cursor_color; break; + case Stag_Highlight: result = &s->highlight_color; break; + case Stag_At_Highlight: result = &s->at_highlight_color; break; + case Stag_Mark: result = &s->mark_color; break; + case Stag_Default: result = &s->default_color; break; + case Stag_Comment: result = &s->comment_color; break; + case Stag_Keyword: result = &s->keyword_color; break; + case Stag_Str_Constant: result = &s->str_constant_color; break; + case Stag_Char_Constant: result = &s->char_constant_color; break; + case Stag_Int_Constant: result = &s->int_constant_color; break; + case Stag_Float_Constant: result = &s->float_constant_color; break; + case Stag_Bool_Constant: result = &s->bool_constant_color; break; + case Stag_Preproc: result = &s->preproc_color; break; + case Stag_Include: result = &s->include_color; break; + case Stag_Special_Character: result = &s->special_character_color; break; + case Stag_Highlight_Junk: result = &s->highlight_junk_color; break; + case Stag_Highlight_White: result = &s->highlight_white_color; break; + case Stag_Paste: result = &s->paste_color; break; + case Stag_Undo: result = &s->undo_color; break; + case Stag_Next_Undo: result = &s->next_undo_color; break; + } + return(result); +} + diff --git a/test_data/lots_of_files/4ed_system.h b/test_data/lots_of_files/4ed_system.h new file mode 100644 index 0000000..76e1c76 --- /dev/null +++ b/test_data/lots_of_files/4ed_system.h @@ -0,0 +1,253 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 21.01.2014 + * + * System functions for project codename "4ed" + * + */ + +// TOP + +struct Plat_Handle{ + u32 d[4]; +}; + +struct Unique_Hash{ + u32 d[4]; +}; + +#define Sys_File_Time_Stamp_Sig(name) u64 name(char *filename) +typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp); + +// TODO(allen): make directory a char* to signal that it must be null terminated +#define Sys_Set_File_List_Sig(name) void name(File_List *file_list, String directory) +typedef Sys_Set_File_List_Sig(System_Set_File_List); + +#define Sys_File_Unique_Hash_Sig(name) Unique_Hash name(char *filename) +typedef Sys_File_Unique_Hash_Sig(System_File_Unique_Hash); + +#define Sys_Post_Clipboard_Sig(name) void name(String str) +typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard); + +#define Sys_Time_Sig(name) u64 name() +typedef Sys_Time_Sig(System_Time); + +// cli +struct CLI_Handles{ + Plat_Handle proc; + Plat_Handle out_read; + Plat_Handle out_write; + u32 scratch_space[4]; + i32 exit; +}; + +#define Sys_CLI_Call_Sig(name) b32 name(char *path, char *script_name, CLI_Handles *cli_out) +typedef Sys_CLI_Call_Sig(System_CLI_Call); + +#define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli) +typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update); + +#define Sys_CLI_Update_Step_Sig(name) b32 name(CLI_Handles *cli, char *dest, u32 max, u32 *amount) +typedef Sys_CLI_Update_Step_Sig(System_CLI_Update_Step); + +#define Sys_CLI_End_Update_Sig(name) b32 name(CLI_Handles *cli) +typedef Sys_CLI_End_Update_Sig(System_CLI_End_Update); + +// coroutine + +#define Coroutine_Function_Sig(name) void name(struct Coroutine *coroutine) +typedef Coroutine_Function_Sig(Coroutine_Function); + +struct Coroutine{ + Plat_Handle plat_handle; + Coroutine_Function *func; + void *yield_handle; + void *in; + void *out; +}; + +#define Sys_Create_Coroutine_Sig(name) Coroutine *name(Coroutine_Function *func) +typedef Sys_Create_Coroutine_Sig(System_Create_Coroutine); + +#define Sys_Launch_Coroutine_Sig(name) Coroutine *name(Coroutine *coroutine, void *in, void *out) +typedef Sys_Launch_Coroutine_Sig(System_Launch_Coroutine); + +#define Sys_Resume_Coroutine_Sig(name) Coroutine *name(Coroutine *coroutine, void *in, void *out) +typedef Sys_Resume_Coroutine_Sig(System_Resume_Coroutine); + +#define Sys_Yield_Coroutine_Sig(name) void name(Coroutine *coroutine) +typedef Sys_Yield_Coroutine_Sig(System_Yield_Coroutine); + +// thread +struct Thread_Context; + +enum Lock_ID{ + FRAME_LOCK, + INPUT_LOCK, + FONT_LOCK, + RENDER_LOCK, + CANCEL_LOCK0, + CANCEL_LOCK1, + CANCEL_LOCK2, + CANCEL_LOCK3, + CANCEL_LOCK4, + CANCEL_LOCK5, + CANCEL_LOCK6, + CANCEL_LOCK7, + LOCK_COUNT +}; + +enum Thread_Group_ID{ + BACKGROUND_THREADS, + THREAD_GROUP_COUNT +}; + +struct Thread_Memory{ + void *data; + i32 size; + i32 id; +}; + +struct Thread_Exchange; +struct System_Functions; + +#define Job_Callback_Sig(name) void name( \ + System_Functions *system, Thread_Context *thread, Thread_Memory *memory, \ + Thread_Exchange *exchange, void *data[2]) +typedef Job_Callback_Sig(Job_Callback); + +struct Job_Data{ + Job_Callback *callback; + void *data[2]; + i32 memory_request; +}; + +struct Full_Job_Data{ + Job_Data job; + + u32 job_memory_index; + u32 running_thread; + b32 finished; + u32 id; +}; + +struct Work_Queue{ + Full_Job_Data jobs[256]; + Plat_Handle semaphore; + volatile u32 write_position; + volatile u32 read_position; +}; + +#define THREAD_NOT_ASSIGNED 0xFFFFFFFF + +#define JOB_ID_WRAP (ArrayCount(queue->jobs) * 4) +#define QUEUE_WRAP (ArrayCount(queue->jobs)) + +struct Thread_Exchange{ + Work_Queue queues[THREAD_GROUP_COUNT]; + volatile u32 force_redraw; +}; + +#define Sys_Post_Job_Sig(name) u32 name(Thread_Group_ID group_id, Job_Data job) +typedef Sys_Post_Job_Sig(System_Post_Job); + +#define Sys_Cancel_Job_Sig(name) void name(Thread_Group_ID group_id, u32 job_id) +typedef Sys_Cancel_Job_Sig(System_Cancel_Job); + +#define Sys_Grow_Thread_Memory_Sig(name) void name(Thread_Memory *memory) +typedef Sys_Grow_Thread_Memory_Sig(System_Grow_Thread_Memory); + +#define Sys_Acquire_Lock_Sig(name) void name(i32 id) +typedef Sys_Acquire_Lock_Sig(System_Acquire_Lock); + +#define Sys_Release_Lock_Sig(name) void name(i32 id) +typedef Sys_Release_Lock_Sig(System_Release_Lock); + +// debug +#define INTERNAL_Sys_Sentinel_Sig(name) Bubble* name() +typedef INTERNAL_Sys_Sentinel_Sig(INTERNAL_System_Sentinel); + +#define INTERNAL_Sys_Get_Thread_States_Sig(name) void name(Thread_Group_ID id, b8 *running, i32 *pending) +typedef INTERNAL_Sys_Get_Thread_States_Sig(INTERNAL_System_Get_Thread_States); + +#define INTERNAL_Sys_Debug_Message_Sig(name) void name(char *message) +typedef INTERNAL_Sys_Debug_Message_Sig(INTERNAL_System_Debug_Message); + +struct System_Functions{ + // files: 3 + System_File_Time_Stamp *file_time_stamp; + System_Set_File_List *set_file_list; + System_File_Unique_Hash *file_unique_hash; + + // file system navigation (4coder_custom.h): 2 + File_Exists_Function *file_exists; + Directory_CD_Function *directory_cd; + + // clipboard: 1 + System_Post_Clipboard *post_clipboard; + + // time: 1 + System_Time *time; + + // coroutine: 4 + System_Create_Coroutine *create_coroutine; + System_Launch_Coroutine *launch_coroutine; + System_Resume_Coroutine *resume_coroutine; + System_Yield_Coroutine *yield_coroutine; + + // cli: 4 + System_CLI_Call *cli_call; + System_CLI_Begin_Update *cli_begin_update; + System_CLI_Update_Step *cli_update_step; + System_CLI_End_Update *cli_end_update; + + // threads: 5 + System_Post_Job *post_job; + System_Cancel_Job *cancel_job; + System_Grow_Thread_Memory *grow_thread_memory; + System_Acquire_Lock *acquire_lock; + System_Release_Lock *release_lock; + + // debug: 3 + INTERNAL_System_Sentinel *internal_sentinel; + INTERNAL_System_Get_Thread_States *internal_get_thread_states; + INTERNAL_System_Debug_Message *internal_debug_message; + + // non-function details + char slash; +}; + +#define FileNameMax (1 << 9) + +struct File_Slot{ + File_Slot *next, *prev; + byte *data; + i32 size, max; + char *filename; + i32 filename_len; + u32 flags; +}; + +enum File_Exchange_Flag{ + FEx_Request = 0x1, + FEx_Ready = 0x2, + FEx_Not_Exist = 0x4, + FEx_Save = 0x8, + FEx_Save_Complete = 0x10, + FEx_Save_Failed = 0x20 +}; + +struct File_Exchange{ + File_Slot available, active, free_list; + File_Slot *files; + i32 num_active, max; +}; + +struct Exchange{ + Thread_Exchange thread; + File_Exchange file; +}; + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_template.cpp b/test_data/lots_of_files/4ed_template.cpp new file mode 100644 index 0000000..22be5e6 --- /dev/null +++ b/test_data/lots_of_files/4ed_template.cpp @@ -0,0 +1,54 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.03.2016 + * + * Templated code. + * + */ + +// TOP + +// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates. +// So if you start getting a wiff of stupidity from this back out immediately! +// +// experience 1: no badness, haven't seen any anoying template errors +// ... + +template<typename T> +inline void +dll_init_sentinel(T *sentinel){ + sentinel->next = sentinel; + sentinel->prev = sentinel; +} + +template<typename T> +inline void +dll_insert(T *pos, T *v){ + v->next = pos->next; + v->prev = pos; + pos->next = v; + v->next->prev = v; +} + +template<typename T> +inline void +dll_insert_back(T *pos, T *v){ + v->prev = pos->prev; + v->next = pos; + pos->prev = v; + v->prev->next = v; +} + +template<typename T> +inline void +dll_remove(T *v){ + v->next->prev = v->prev; + v->prev->next = v->next; +} + +// for(dll_items(iterator, sentinel_ptr)){...} +#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next) + +// BOTTOM + diff --git a/test_data/lots_of_files/4ed_ttf.cpp b/test_data/lots_of_files/4ed_ttf.cpp new file mode 100644 index 0000000..d80583a --- /dev/null +++ b/test_data/lots_of_files/4ed_ttf.cpp @@ -0,0 +1,360 @@ +/* + * YOUR INFO HERE! + */ + +// TOP + +typedef unsigned int Fixed16_16; + +struct Offset_Table{ + Fixed16_16 version; + unsigned short num_tables; + unsigned short search_range; + unsigned short entry_selector; + unsigned short range_shift; +}; + +struct Table_Directory_Entry{ + unsigned long tag; + unsigned long check_sum; + unsigned long offset; + unsigned long length; +}; + +#include <stdio.h> +#include <stdlib.h> + +struct Data{ + char *data; + int size; +}; + +Data +open_file(const char *filename){ + Data result = {}; + FILE *file; + file = fopen(filename, "rb"); + if (file){ + fseek(file, 0, SEEK_END); + result.size = ftell(file); + fseek(file, 0, SEEK_SET); + if (result.size > 0){ + result.data = (char*)malloc(result.size); + fread(result.data, result.size, 1, file); + } + fclose(file); + } + return(result); +} + +void +print(Offset_Table *offset){ + printf("version %d\n", offset->version >> 16); + printf("number of tables %d\n", (int)(offset->num_tables)); + printf("search range %d\n", (int)(offset->search_range)); + printf("entry selector %d\n", (int)(offset->entry_selector)); + printf("range shift %d\n", (int)(offset->range_shift)); +} + +void +print(Table_Directory_Entry *entry){ + printf("tag %.4s\n", &entry->tag); + printf("check sum %08x\n", entry->check_sum); + printf("offset %d\n", entry->offset); + printf("length %d\n", entry->length); +} + +void +byte_reverse(void *ptr, int len){ + char *c; + int i,j; + char t; + c = (char*)ptr; + for (i = 0, j = len-1; i < j; ++i, --j){ + t = c[i]; + c[i] = c[j]; + c[j] = t; + } +} + +void +byte_fix(Offset_Table *offset){ + byte_reverse(&offset->version, 4); + byte_reverse(&offset->num_tables, 2); + byte_reverse(&offset->search_range, 2); + byte_reverse(&offset->entry_selector, 2); + byte_reverse(&offset->range_shift, 2); +} + +void +byte_fix(Table_Directory_Entry *entry){ + byte_reverse(&entry->check_sum, 4); + byte_reverse(&entry->offset, 4); + byte_reverse(&entry->length, 4); +} + +struct cmap_Header{ + unsigned short version; + unsigned short num_subtables; +}; + +struct cmap_Subtable_Entry{ + unsigned short plat_id; + unsigned short plat_encoding_id; + unsigned long offset_from_cmap; +}; + +void +byte_fix(cmap_Header *header){ + byte_reverse(&header->version, 2); + byte_reverse(&header->num_subtables, 2); +} + +void +print(cmap_Header *header){ + printf("cmap tables:\n"); + printf("\tversion %d\n", (int)(header->version)); + printf("\tsubtables %d\n", (int)(header->num_subtables)); +} + +void +byte_fix(cmap_Subtable_Entry *entry){ + byte_reverse(&entry->plat_id, 2); + byte_reverse(&entry->plat_encoding_id, 2); + byte_reverse(&entry->offset_from_cmap, 4); +} + +struct cmap_Subtable_Format4_Header{ + unsigned short format; + unsigned short length; + unsigned short version; + unsigned short segment_count_2; + unsigned short search_range; + unsigned short entry_selector; + unsigned short range_shift; +}; + +void +print(cmap_Subtable_Entry *entry){ + printf("\tplatform id %d\n", (int)(entry->plat_id)); + printf("\tencoding id %d\n", (int)(entry->plat_encoding_id)); + printf("\toffset from cmap %d\n", (int)(entry->offset_from_cmap)); +} + +void +byte_fix(cmap_Subtable_Format4_Header *header){ + byte_reverse(&header->length, 2); + byte_reverse(&header->version, 2); + byte_reverse(&header->segment_count_2, 2); + byte_reverse(&header->search_range, 2); + byte_reverse(&header->entry_selector, 2); + byte_reverse(&header->range_shift, 2); +} + +void +print(cmap_Subtable_Format4_Header *header){ + printf("\t\tlength %d\n", header->length); + printf("\t\tversion %d\n", header->version); + printf("\t\tsegment count doubled %d\n", header->segment_count_2); + printf("\t\tsearch range %d\n", header->search_range); + printf("\t\tentry selector %d\n", header->entry_selector); + printf("\t\trange shift %d\n", header->range_shift); +} + +struct cmap_Subtable_Format4_Segments{ + unsigned short *end_code, *start_code; + unsigned short *id_delta, *id_range_offset; +}; + +void +byte_fix(cmap_Subtable_Format4_Segments segs, int segment_count){ + for (int i = 0; i < segment_count; ++i){ + byte_reverse(segs.end_code + i, 2); + } + + for (int i = 0; i < segment_count; ++i){ + byte_reverse(segs.start_code + i, 2); + } + + for (int i = 0; i < segment_count; ++i){ + byte_reverse(segs.id_delta + i, 2); + } + + for (int i = 0; i < segment_count; ++i){ + byte_reverse(segs.id_range_offset + i, 2); + } +} + +void +print(cmap_Subtable_Format4_Segments segs, int i){ + printf("\t\tsegment %d\n", i); + printf("\t\tend code %d\n", (int)(segs.end_code[i])); + printf("\t\tstart code %d\n", (int)(segs.start_code[i])); + printf("\t\tid delta %d\n", (int)(segs.id_delta[i])); + printf("\t\tid range offset %d\n", (int)(segs.id_range_offset[i])); +} + +void +parse_cmap_subtable4(char *start){ + char *cursor = start; + cmap_Subtable_Format4_Header *header = + (cmap_Subtable_Format4_Header*)cursor; + cursor = (char*)(header + 1); + + byte_fix(header); + print(header); + + int segment_count = (header->segment_count_2 >> 1); + + cmap_Subtable_Format4_Segments segs; + + segs.end_code = (unsigned short*)cursor; + cursor = (char*)(segs.end_code + segment_count); + cursor = cursor + sizeof(unsigned short); + + segs.start_code = (unsigned short*)cursor; + cursor = (char*)(segs.start_code + segment_count); + + segs.id_delta = (unsigned short*)cursor; + cursor = (char*)(segs.id_delta + segment_count); + + segs.id_range_offset = (unsigned short*)cursor; + cursor = (char*)(segs.id_range_offset + segment_count); + + byte_fix(segs, segment_count); + for (int i = 0; i < segment_count; ++i){ + printf("\n"); + print(segs, i); + } +} + +void +parse_cmap_subtable(char *start){ + char *cursor = start; + short *format = (short*)cursor; + byte_reverse(format, 2); + printf("\t\tformat %d\n", (int)(*format)); + + switch (*format){ + case 4: + parse_cmap_subtable4(start); + break; + } +} + +void +parse_cmap(char *start){ + char *cursor = start; + cmap_Header *header = (cmap_Header*)cursor; + cursor = (char*)(header + 1); + + byte_fix(header); + print(header); + + cmap_Subtable_Entry *entry = (cmap_Subtable_Entry*)cursor; + for (int i = 0; i < header->num_subtables; ++i, ++entry){ + byte_fix(entry); + printf("\n"); + print(entry); + + if (entry->plat_id == 3 && entry->plat_encoding_id == 1){ + printf("\n\tMicrosoft Unicode table:\n"); + parse_cmap_subtable(start + entry->offset_from_cmap); + } + } +} + +struct glyf_Glyph_Header{ + short num_contours; + short x_min; + short x_max; + short y_min; + short y_max; +}; + +void +byte_fix(glyf_Glyph_Header *header){ + byte_reverse(&header->num_contours, 2); + byte_reverse(&header->x_min, 2); + byte_reverse(&header->x_max, 2); + byte_reverse(&header->y_min, 2); + byte_reverse(&header->y_max, 2); +} + +void +print(glyf_Glyph_Header *header){ + printf("\tcontours %d\n", (int)(header->num_contours)); + printf("\tx min %d\n", (int)(header->x_min)); + printf("\tx max %d\n", (int)(header->x_max)); + printf("\ty min %d\n", (int)(header->y_min)); + printf("\ty max %d\n", (int)(header->y_max)); +} + +void +parse_glyf(char *start){ + char *cursor = start; + glyf_Glyph_Header *header = (glyf_Glyph_Header*)cursor; + cursor = (char*)(header + 1); + + byte_fix(header); + print(header); +} + +#define TTF_Tag(a,b,c,d) ((a) + ((b) << 8) + ((c) << 16) + ((d) << 24)) +#define TTF_Tag_cmap TTF_Tag('c', 'm', 'a', 'p') + +#define TTF_Tag_glyf TTF_Tag('g', 'l', 'y', 'f') +#define TTF_Tag_fpgm TTF_Tag('f', 'p', 'g', 'm') +#define TTF_Tag_prep TTF_Tag('p', 'r', 'e', 'p') +#define TTF_Tag_cvt TTF_Tag('c', 'v', 't', ' ') +#define TTF_Tag_maxp TTF_Tag('m', 'a', 'x', 'p') + + +int +main(){ + Data file; + char *filename; + + filename = "test.ttf"; + file = open_file(filename); + if (file.data == 0){ + printf("could not open %s\n", filename); + return (1); + } + + char *cursor; + Offset_Table *offset; + + cursor = file.data; + offset = (Offset_Table*)cursor; + cursor = (char*)(offset + 1); + + + Table_Directory_Entry *directory_entries = (Table_Directory_Entry*)cursor; + + byte_fix(offset); + print(offset); + + int table_number = offset->num_tables; + + Table_Directory_Entry *entry = directory_entries; + for (int i = 0; i < table_number; ++i, ++entry){ + printf("\n"); + byte_fix(entry); + print(entry); + + switch (entry->tag){ + case TTF_Tag_cmap: + parse_cmap(file.data + entry->offset); + break; + + case TTF_Tag_glyf: + parse_glyf(file.data + entry->offset); + break; + } + } + + return (0); +} + +// BOTTOM diff --git a/test_data/lots_of_files/4ed_win32_keyboard.cpp b/test_data/lots_of_files/4ed_win32_keyboard.cpp new file mode 100644 index 0000000..dbe837c --- /dev/null +++ b/test_data/lots_of_files/4ed_win32_keyboard.cpp @@ -0,0 +1,31 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 12.17.2014 + * + * Win32-US Keyboard layer for 4coder + * + */ + +// TOP + +#include "4ed_keyboard.cpp" + +internal void +keycode_init(){ + keycode_lookup_table[VK_BACK] = key_back; + keycode_lookup_table[VK_DELETE] = key_del; + keycode_lookup_table[VK_UP] = key_up; + keycode_lookup_table[VK_DOWN] = key_down; + keycode_lookup_table[VK_LEFT] = key_left; + keycode_lookup_table[VK_RIGHT] = key_right; + keycode_lookup_table[VK_INSERT] = key_insert; + keycode_lookup_table[VK_HOME] = key_home; + keycode_lookup_table[VK_END] = key_end; + keycode_lookup_table[VK_PRIOR] = key_page_up; + keycode_lookup_table[VK_NEXT] = key_page_down; + keycode_lookup_table[VK_ESCAPE] = key_esc; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4tech_keycodes.h b/test_data/lots_of_files/4tech_keycodes.h new file mode 100644 index 0000000..4a94748 --- /dev/null +++ b/test_data/lots_of_files/4tech_keycodes.h @@ -0,0 +1,69 @@ +enum Key_Code_Names{ +key_back = 1, +key_up = 2, +key_down = 3, +key_left = 4, +key_right = 5, +key_del = 6, +key_insert = 7, +key_home = 8, +key_end = 11, +key_page_up = 12, +key_page_down = 13, +key_esc = 14, +key_mouse_left = 15, +key_mouse_right = 16, +key_f1 = 127, +key_f2 = 128, +key_f3 = 129, +key_f4 = 130, +key_f5 = 131, +key_f6 = 132, +key_f7 = 133, +key_f8 = 134, +key_f9 = 135, +key_f10 = 136, +key_f11 = 137, +key_f12 = 138, +key_f13 = 139, +key_f14 = 140, +key_f15 = 141, +key_f16 = 142, +}; +static char* +global_key_name(int key_code, int *size){ +char *result = 0; +switch(key_code){ +case key_back: result = "back"; *size = sizeof("back")-1; break; +case key_up: result = "up"; *size = sizeof("up")-1; break; +case key_down: result = "down"; *size = sizeof("down")-1; break; +case key_left: result = "left"; *size = sizeof("left")-1; break; +case key_right: result = "right"; *size = sizeof("right")-1; break; +case key_del: result = "del"; *size = sizeof("del")-1; break; +case key_insert: result = "insert"; *size = sizeof("insert")-1; break; +case key_home: result = "home"; *size = sizeof("home")-1; break; +case key_end: result = "end"; *size = sizeof("end")-1; break; +case key_page_up: result = "page_up"; *size = sizeof("page_up")-1; break; +case key_page_down: result = "page_down"; *size = sizeof("page_down")-1; break; +case key_esc: result = "esc"; *size = sizeof("esc")-1; break; +case key_mouse_left: result = "mouse_left"; *size = sizeof("mouse_left")-1; break; +case key_mouse_right: result = "mouse_right"; *size = sizeof("mouse_right")-1; break; +case key_f1: result = "f1"; *size = sizeof("f1")-1; break; +case key_f2: result = "f2"; *size = sizeof("f2")-1; break; +case key_f3: result = "f3"; *size = sizeof("f3")-1; break; +case key_f4: result = "f4"; *size = sizeof("f4")-1; break; +case key_f5: result = "f5"; *size = sizeof("f5")-1; break; +case key_f6: result = "f6"; *size = sizeof("f6")-1; break; +case key_f7: result = "f7"; *size = sizeof("f7")-1; break; +case key_f8: result = "f8"; *size = sizeof("f8")-1; break; +case key_f9: result = "f9"; *size = sizeof("f9")-1; break; +case key_f10: result = "f10"; *size = sizeof("f10")-1; break; +case key_f11: result = "f11"; *size = sizeof("f11")-1; break; +case key_f12: result = "f12"; *size = sizeof("f12")-1; break; +case key_f13: result = "f13"; *size = sizeof("f13")-1; break; +case key_f14: result = "f14"; *size = sizeof("f14")-1; break; +case key_f15: result = "f15"; *size = sizeof("f15")-1; break; +case key_f16: result = "f16"; *size = sizeof("f16")-1; break; +} +return(result); +} diff --git a/test_data/lots_of_files/4tech_math.cpp b/test_data/lots_of_files/4tech_math.cpp new file mode 100644 index 0000000..ed307e0 --- /dev/null +++ b/test_data/lots_of_files/4tech_math.cpp @@ -0,0 +1,695 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 15.05.2015 + * + * Math functions for 4coder + * + */ + +// TOP + +/* + * Scalar operators + */ + +#define C_MATH 1 + +#define DEG_TO_RAD 0.0174533f +#define RAD_TO_DEG 57.295780f + +#if C_MATH +#include <math.h> +#endif + +inline real32 +ABS(real32 x){ +#if C_MATH + return abs(x); +#endif +} + +inline real32 +MOD(real32 x, i32 m){ +#if C_MATH + real32 whole, frac; + frac = modf(x, &whole); + return ((i32)(whole) % m) + frac; +#endif +} + +inline real32 +SQRT(real32 x){ +#if C_MATH + return sqrt(x); +#endif +} + +inline real32 +SIN(real32 x_degrees){ +#if C_MATH + return sinf(x_degrees * DEG_TO_RAD); +#endif +} + +inline real32 +COS(real32 x_degrees){ +#if C_MATH + return cosf(x_degrees * DEG_TO_RAD); +#endif +} + +inline f32 +ATAN_DEG(f32 y, f32 x){ +#if C_MATH + return atan2f(y, x) * RAD_TO_DEG; +#endif +} + +inline f32 +POW(f32 base, f32 exp){ +#if C_MATH + return pow(base, exp); +#endif +} + +/* + * Rounding + */ + +inline i32 +TRUNC32(real32 x) { return (i32)x; } + +inline i32 +FLOOR32(real32 x) { return (i32)(x)-((x!=(i32)(x) && x<0)?1:0); } + +inline i32 +CEIL32(real32 x) { return (i32)(x)+((x!=(i32)(x) && x>0)?1:0); } + +inline i32 +ROUND32(real32 x) { return FLOOR32(x + .5f); } + +inline i32 +DIVCEIL32(i32 n, i32 d) { + i32 q = (n/d); + return q + (q*d < n); +} + +inline real32 +FRACPART32(real32 x) { return x - (i32)x; } + +/* + * Vectors + */ + +struct Vec2{ + union{ + struct{ + real32 x, y; + }; + struct{ + real32 v[2]; + }; + }; +}; + +struct Vec3{ + union{ + struct{ + real32 x, y, z; + }; + struct{ + real32 r, g, b; + }; + struct{ + Vec2 xy; + real32 _z; + }; + struct{ + real32 _x; + Vec2 yz; + }; + struct{ + real32 v[3]; + }; + }; +}; + +struct Vec4{ + union{ + struct{ + real32 r, g, b, a; + }; + + struct{ + real32 h, s, l, __a; + }; + struct{ + real32 x, y, z, w; + }; + struct{ + Vec3 rgb; + real32 _a; + }; + struct{ + Vec3 xyz; + real32 _w; + }; + struct{ + real32 _x; + Vec3 yzw; + }; + struct{ + real32 v[4]; + }; + }; +}; + +inline Vec2 +V2(real32 x, real32 y){ + Vec2 result; + result.x = x; + result.y = y; + return result; +} + +inline Vec3 +V3(real32 x, real32 y, real32 z){ + Vec3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +inline Vec4 +V4(real32 x, real32 y, real32 z, real32 w){ + Vec4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +inline Vec2 +operator+(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + return result; +} + +inline Vec3 +operator+(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + return result; +} + +inline Vec4 +operator+(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + return result; +} + +inline Vec2 +operator-(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + return result; +} + +inline Vec3 +operator-(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + return result; +} + +inline Vec4 +operator-(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + return result; +} + +inline Vec2 +operator*(Vec2 a, real32 k){ + Vec2 result; + result.x = a.x * k; + result.y = a.y * k; + return result; +} + +inline Vec3 +operator*(Vec3 a, real32 k){ + Vec3 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + return result; +} + +inline Vec4 +operator*(Vec4 a, real32 k){ + Vec4 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + result.w = a.w * k; + return result; +} + +inline Vec2 +operator*(real32 k, Vec2 a){ + Vec2 result; + result.x = a.x * k; + result.y = a.y * k; + return result; +} + +inline Vec3 +operator*(real32 k, Vec3 a){ + Vec3 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + return result; +} + +inline Vec4 +operator*(real32 k, Vec4 a){ + Vec4 result; + result.x = a.x * k; + result.y = a.y * k; + result.z = a.z * k; + result.w = a.w * k; + return result; +} + +inline Vec2& +operator+=(Vec2 &a, Vec2 b){ + a = (a + b); + return a; +} + +inline Vec3& +operator+=(Vec3 &a, Vec3 b){ + a = (a + b); + return a; +} + +inline Vec4& +operator+=(Vec4 &a, Vec4 b){ + a = (a + b); + return a; +} + +inline Vec2& +operator-=(Vec2 &a, Vec2 b){ + a = (a - b); + return a; +} + +inline Vec3& +operator-=(Vec3 &a, Vec3 b){ + a = (a - b); + return a; +} + +inline Vec4& +operator-=(Vec4 &a, Vec4 b){ + a = (a - b); + return a; +} + +inline Vec2& +operator*=(Vec2 &a, real32 k){ + a = (a * k); + return a; +} + +inline Vec3& +operator*=(Vec3 &a, real32 k){ + a = (a * k); + return a; +} + +inline Vec4& +operator*=(Vec4 &a, real32 k){ + a = (a * k); + return a; +} + +inline real32 +dot(Vec2 a, Vec2 b){ + real32 result; + result = a.x*b.x + a.y*b.y; + return result; +} + +inline real32 +dot(Vec3 a, Vec3 b){ + real32 result; + result = a.x*b.x + a.y*b.y + a.z*b.z; + return result; +} + +inline real32 +dot(Vec4 a, Vec4 b){ + real32 result; + result = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w; + return result; +} + +inline Vec3 +cross(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.y*b.z - b.y*a.z; + result.y = a.z*b.x - b.z*a.x; + result.z = a.x*b.y - b.x*a.y; + return result; +} + +inline Vec2 +hadamard(Vec2 a, Vec2 b){ + Vec2 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + return result; +} + +inline Vec3 +hadamard(Vec3 a, Vec3 b){ + Vec3 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + result.z = a.z*b.z; + return result; +} + +inline Vec4 +hadamard(Vec4 a, Vec4 b){ + Vec4 result; + result.x = a.x*b.x; + result.y = a.y*b.y; + result.z = a.z*b.z; + result.w = a.w*b.w; + return result; +} + +inline Vec2 +perp(Vec2 v){ + Vec2 result; + result.x = -v.y; + result.y = v.x; + return result; +} + +inline Vec2 +polar_to_cartesian(real32 theta_degrees, real32 length){ + Vec2 result; + result.x = COS(theta_degrees)*length; + result.y = SIN(theta_degrees)*length; + return result; +} + +inline Vec2 +cis(f32 theta){ + Vec2 result; + result.x = COS(theta); + result.y = SIN(theta); + return result; +} + +inline Vec2 +rotate(Vec2 v, real32 theta_degrees){ + Vec2 result; + real32 c, s; + c = COS(theta_degrees); + s = SIN(theta_degrees); + result.x = v.x*c - v.y*s; + result.y = v.x*s + v.y*c; + return result; +} + +inline real32 +vector_projection(Vec2 x, Vec2 target){ + real32 target_magnitude = SQRT(dot(target, target)); + Vec2 unit_target = target * (1 / target_magnitude); + real32 result = dot(x, unit_target); + return(result); +} + +inline Vec2 +normalize(Vec2 x){ + f32 d = dot(x, x); + d = SQRT(d); + x *= (1.f/d); + return(x); +} + +inline Vec2 +normalize_radius(Vec2 x, f32 r){ + f32 d = dot(x, x); + d = SQRT(d); + r = r/d; + x *= r; + return(x); +} + +inline f32 +argument_degrees(Vec2 v){ + f32 r = ATAN_DEG(v.y, v.x); + return(r); +} + +/* + * Coordinates + */ + +struct Matrix2{ + Vec2 x_axis; + Vec2 y_axis; +}; + +internal Matrix2 +invert(Vec2 x_axis, Vec2 y_axis){ + Matrix2 result = {}; + real32 det = 1.f / (x_axis.x*y_axis.y - x_axis.y*y_axis.x); + result.x_axis.x = y_axis.y*det; + result.y_axis.x = -y_axis.x*det; + result.x_axis.y = -x_axis.y*det; + result.y_axis.y = x_axis.x*det; + return result; +} + +internal Matrix2 +invert(Matrix2 m){ + Matrix2 result = {}; + real32 det = 1.f / (m.x_axis.x*m.y_axis.y - m.x_axis.y*m.y_axis.x); + result.x_axis.x = m.y_axis.y*det; + result.y_axis.x = -m.y_axis.x*det; + result.x_axis.y = -m.x_axis.y*det; + result.y_axis.y = m.x_axis.x*det; + return result; +} + +/* + * Lerps, Clamps, Thresholds, Etc + */ + +inline real32 +lerp(real32 a, real32 t, real32 b){ + return a + (b-a)*t; +} + +inline Vec2 +lerp(Vec2 a, real32 t, Vec2 b){ + return a + (b-a)*t; +} + +inline Vec3 +lerp(Vec3 a, real32 t, Vec3 b){ + return a + (b-a)*t; +} + +inline Vec4 +lerp(Vec4 a, real32 t, Vec4 b){ + return a + (b-a)*t; +} + +inline real32 +unlerp(real32 a, real32 x, real32 b){ + return (x - a) / (b - a); +} + +inline real32 +clamp(real32 a, real32 n, real32 z){ + return (n<a)?(a):((n>z)?(z):n); +} + +/* + * Color + */ + +// TODO(allen): Convert colors to Vec4 +inline internal u32 +color_blend(u32 a, real32 t, u32 b){ + union{ + u8 byte[4]; + u32 comp; + } A, B, R; + + A.comp = a; + B.comp = b; + + R.byte[0] = (u8)lerp(A.byte[0], t, B.byte[0]); + R.byte[1] = (u8)lerp(A.byte[1], t, B.byte[1]); + R.byte[2] = (u8)lerp(A.byte[2], t, B.byte[2]); + R.byte[3] = (u8)lerp(A.byte[3], t, B.byte[3]); + + return R.comp; +} + +internal Vec3 +unpack_color3(u32 color){ + Vec3 result; + result.r = ((color >> 16) & 0xFF) / 255.f; + result.g = ((color >> 8) & 0xFF) / 255.f; + result.b = ((color >> 0) & 0xFF) / 255.f; + return result; +} + +internal Vec4 +unpack_color4(u32 color){ + Vec4 result; + result.a = ((color >> 24) & 0xFF) / 255.f; + result.r = ((color >> 16) & 0xFF) / 255.f; + result.g = ((color >> 8) & 0xFF) / 255.f; + result.b = ((color >> 0) & 0xFF) / 255.f; + return result; +} + +internal u32 +pack_color4(Vec4 color){ + u32 result = + ((u8)(color.a * 255) << 24) | + ((u8)(color.r * 255) << 16) | + ((u8)(color.g * 255) << 8) | + ((u8)(color.b * 255) << 0); + return result; +} + +internal Vec4 +rgba_to_hsla(Vec4 rgba){ + Vec4 hsla = {}; + real32 max, min, delta; + i32 maxc; + hsla.a = rgba.a; + max = rgba.r; min = rgba.r; + maxc = 0; + if (rgba.r < rgba.g){ + max = rgba.g; + maxc = 1; + } + if (rgba.b > max){ + max = rgba.b; + maxc = 2; + } + if (rgba.r > rgba.g){ + min = rgba.g; + } + if (rgba.b < min){ + min = rgba.b; + } + delta = max - min; + + hsla.z = (max + min) * .5f; + if (delta == 0){ + hsla.x = 0.f; + hsla.y = 0.f; + } + else{ + switch (maxc){ + case 0: + { + hsla.x = (rgba.g - rgba.b) / delta; + hsla.x += (rgba.g < rgba.b) * 6.f; + }break; + + case 1: + { + hsla.x = (rgba.b - rgba.r) / delta; + hsla.x += 2.f; + }break; + + case 2: + { + hsla.x = (rgba.r - rgba.g) / delta; + hsla.x += 4.f; + }break; + } + hsla.x *= (1/6.f); // * 60 / 360 + hsla.y = delta / (1.f - ABS(2.f*hsla.z - 1.f)); + } + + return hsla; +} + +internal Vec4 +hsla_to_rgba(Vec4 hsla){ + Vec4 rgba = {}; + real32 C, X, m; + i32 H; + rgba.a = hsla.a; + C = (1.f - ABS(2*hsla.z - 1.f)) * hsla.y; + X = C * (1.f-ABS(MOD(hsla.x*6.f, 2)-1.f)); + m = hsla.z - C*.5f; + H = FLOOR32(hsla.x * 6.f); + switch (H){ + case 0: + rgba.r = C; rgba.g = X; rgba.b = 0; + break; + + case 1: + rgba.r = X; rgba.g = C; rgba.b = 0; + break; + + case 2: + rgba.r = 0; rgba.g = C; rgba.b = X; + break; + + case 3: + rgba.r = 0; rgba.g = X; rgba.b = C; + break; + + case 4: + rgba.r = X; rgba.g = 0; rgba.b = C; + break; + + case 5: + rgba.r = C; rgba.g = 0; rgba.b = X; + break; + } + rgba.r += m; + rgba.g += m; + rgba.b += m; + return rgba; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/4tech_string.h b/test_data/lots_of_files/4tech_string.h new file mode 100644 index 0000000..04ce5d8 --- /dev/null +++ b/test_data/lots_of_files/4tech_string.h @@ -0,0 +1,1618 @@ + +// TOP + +#if defined(FSTRING_IMPLEMENTATION) && defined(FSTRING_GUARD) +#undef FSTRING_IMPLEMENTATION +#endif + +#include <stdint.h> + +#ifndef FSTRING_LINK +# define FSTRING_LINK static +#endif + +#ifndef FSTRING_INLINE +# define FSTRING_INLINE inline +#endif + +#ifndef FSTRING_STRUCT +#define FSTRING_STRUCT +typedef struct String{ + char *str; + int32_t size; + int32_t memory_size; +} String; + +typedef struct Offset_String{ + int32_t offset; + int32_t size; +} Offset_String; +#endif + +#ifndef fstr_bool +# define fstr_bool int32_t +#endif + +#ifndef literal +# define literal(s) (s), (sizeof(s)-1) +#endif + +#ifndef FCODER_STRING_H +#define FCODER_STRING_H + +FSTRING_INLINE fstr_bool char_is_slash(char c); +FSTRING_INLINE char char_to_upper(char c); +FSTRING_INLINE char char_to_lower(char c); +FSTRING_INLINE fstr_bool char_is_whitespace(char c); +FSTRING_INLINE fstr_bool char_is_alpha_numeric(char c); +FSTRING_INLINE fstr_bool char_is_alpha_numeric_true(char c); +FSTRING_INLINE fstr_bool char_is_alpha(char c); +FSTRING_INLINE fstr_bool char_is_alpha_true(char c); +FSTRING_INLINE fstr_bool char_is_hex(char c); +FSTRING_INLINE fstr_bool char_is_numeric(char c); +FSTRING_INLINE String string_zero(void); +FSTRING_INLINE String make_string_max(void *str, int32_t size, int32_t mem_size); +FSTRING_INLINE String make_string(void *str, int32_t size); +#ifndef make_lit_string +# define make_lit_string(s) (make_string_max((char*)(s), sizeof(s)-1, sizeof(s))) +#endif +#ifndef make_fixed_width_string +# define make_fixed_width_string(s) (make_string_max((char*)(s), 0, sizeof(s))) +#endif +#ifndef expand_str +# define expand_str(s) ((s).str), ((s).size) +#endif +FSTRING_LINK int32_t str_size(char *str); +FSTRING_INLINE String make_string_slowly(void *str); +FSTRING_INLINE String substr(String str, int32_t start); +FSTRING_INLINE String substr_start_size(String str, int32_t start, int32_t size); +FSTRING_LINK String skip_whitespace(String str); +FSTRING_LINK String chop_whitespace(String str); +FSTRING_LINK String skip_chop_whitespace(String str); +FSTRING_INLINE String tailstr(String str); +FSTRING_LINK fstr_bool match_cc(char *a, char *b); +FSTRING_LINK fstr_bool match_sc(String a, char *b); +FSTRING_INLINE fstr_bool match_cs(char *a, String b); +FSTRING_LINK fstr_bool match_ss(String a, String b); +FSTRING_LINK fstr_bool match_part_ccl(char *a, char *b, int32_t *len); +FSTRING_LINK fstr_bool match_part_scl(String a, char *b, int32_t *len); +FSTRING_INLINE fstr_bool match_part_cc(char *a, char *b); +FSTRING_INLINE fstr_bool match_part_sc(String a, char *b); +FSTRING_LINK fstr_bool match_part_cs(char *a, String b); +FSTRING_LINK fstr_bool match_part_ss(String a, String b); +FSTRING_LINK fstr_bool match_insensitive_cc(char *a, char *b); +FSTRING_LINK fstr_bool match_insensitive_sc(String a, char *b); +FSTRING_INLINE fstr_bool match_insensitive_cs(char *a, String b); +FSTRING_LINK fstr_bool match_insensitive_ss(String a, String b); +FSTRING_LINK fstr_bool match_part_insensitive_ccl(char *a, char *b, int32_t *len); +FSTRING_LINK fstr_bool match_part_insensitive_scl(String a, char *b, int32_t *len); +FSTRING_INLINE fstr_bool match_part_insensitive_cc(char *a, char *b); +FSTRING_INLINE fstr_bool match_part_insensitive_sc(String a, char *b); +FSTRING_LINK fstr_bool match_part_insensitive_cs(char *a, String b); +FSTRING_LINK fstr_bool match_part_insensitive_ss(String a, String b); +FSTRING_LINK int32_t compare_cc(char *a, char *b); +FSTRING_LINK int32_t compare_sc(String a, char *b); +FSTRING_INLINE int32_t compare_cs(char *a, String b); +FSTRING_LINK int32_t compare_ss(String a, String b); +FSTRING_LINK int32_t find_c(char *str, int32_t start, char character); +FSTRING_LINK int32_t find_s(String str, int32_t start, char character); +FSTRING_LINK int32_t find_chars_c(char *str, int32_t start, char *characters); +FSTRING_LINK int32_t find_chars_s(String str, int32_t start, char *characters); +FSTRING_LINK int32_t find_substr_c(char *str, int32_t start, String seek); +FSTRING_LINK int32_t find_substr_s(String str, int32_t start, String seek); +FSTRING_LINK int32_t rfind_substr(String str, int32_t start, String seek); +FSTRING_LINK int32_t find_substr_insensitive_c(char *str, int32_t start, String seek); +FSTRING_LINK int32_t find_substr_insensitive_s(String str, int32_t start, String seek); +FSTRING_INLINE fstr_bool has_substr_c(char *s, String seek); +FSTRING_INLINE fstr_bool has_substr_s(String s, String seek); +FSTRING_INLINE fstr_bool has_substr_insensitive_c(char *s, String seek); +FSTRING_INLINE fstr_bool has_substr_insensitive_s(String s, String seek); +FSTRING_LINK int32_t copy_fast_unsafe_cc(char *dest, char *src); +FSTRING_LINK int32_t copy_fast_unsafe_cs(char *dest, String src); +FSTRING_LINK fstr_bool copy_checked_ss(String *dest, String src); +FSTRING_LINK fstr_bool copy_partial_sc(String *dest, char *src); +FSTRING_LINK fstr_bool copy_partial_ss(String *dest, String src); +FSTRING_INLINE int32_t copy_cc(char *dest, char *src); +FSTRING_INLINE void copy_ss(String *dest, String src); +FSTRING_INLINE void copy_sc(String *dest, char *src); +FSTRING_LINK fstr_bool append_checked_ss(String *dest, String src); +FSTRING_LINK fstr_bool append_partial_sc(String *dest, char *src); +FSTRING_LINK fstr_bool append_partial_ss(String *dest, String src); +FSTRING_LINK fstr_bool append_char(String *dest, char c); +FSTRING_INLINE fstr_bool append_s(String *dest, String src); +FSTRING_INLINE fstr_bool append_c(String *dest, char *src); +FSTRING_LINK fstr_bool terminate_with_null(String *str); +FSTRING_LINK fstr_bool append_padding(String *dest, char c, int32_t target_size); +FSTRING_LINK void replace_char(String *str, char replace, char with); +FSTRING_LINK int32_t int_to_str_size(int32_t x); +FSTRING_LINK fstr_bool int_to_str(String *dest, int32_t x); +FSTRING_LINK fstr_bool append_int_to_str(String *dest, int32_t x); +FSTRING_LINK int32_t u64_to_str_size(uint64_t x); +FSTRING_LINK fstr_bool u64_to_str(String *dest, uint64_t x); +FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x); +FSTRING_LINK int32_t float_to_str_size(float x); +FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x); +FSTRING_LINK fstr_bool float_to_str(String *dest, float x); +FSTRING_LINK fstr_bool str_is_int_s(String str); +FSTRING_LINK int32_t str_to_int_c(char *str); +FSTRING_LINK int32_t str_to_int_s(String str); +FSTRING_LINK int32_t hexchar_to_int(char c); +FSTRING_LINK char int_to_hexchar(int32_t x); +FSTRING_LINK uint32_t hexstr_to_int(String str); +FSTRING_LINK fstr_bool color_to_hexstr(String *s, uint32_t color); +FSTRING_LINK fstr_bool hexstr_to_color(String s, uint32_t *out); +FSTRING_LINK int32_t reverse_seek_slash_pos(String str, int32_t pos); +FSTRING_INLINE int32_t reverse_seek_slash(String str); +FSTRING_INLINE String front_of_directory(String dir); +FSTRING_INLINE String path_of_directory(String dir); +FSTRING_LINK fstr_bool set_last_folder_c(String *dir, char *folder_name, char slash); +FSTRING_LINK fstr_bool set_last_folder_s(String *dir, String folder_name, char slash); +FSTRING_LINK String file_extension(String str); +FSTRING_LINK fstr_bool remove_extension(String *str); +FSTRING_LINK fstr_bool remove_last_folder(String *str); +FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index); + +#endif + + +// +// Character Helpers +// + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_slash(char c) +{ + return (c == '\\' || c == '/'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE char +char_to_upper(char c) +{ + return (c >= 'a' && c <= 'z') ? c + (char)('A' - 'a') : c; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE char +char_to_lower(char c) +{ + return (c >= 'A' && c <= 'Z') ? c - (char)('A' - 'a') : c; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_whitespace(char c) +{ + return (c == ' ' || c == '\n' || c == '\r' || c == '\t'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_alpha_numeric(char c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_alpha_numeric_true(char c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_alpha(char c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_alpha_true(char c) +{ + return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_hex(char c) +{ + return c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +char_is_numeric(char c) +{ + return (c >= '0' && c <= '9'); +} +#endif + + +// +// String Making Functions +// + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +string_zero() +{ + String str={0}; + return(str); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +make_string_max(void *str, int32_t size, int32_t mem_size) +{ + String result; + result.str = (char*)str; + result.size = size; + result.memory_size = mem_size; + return result; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +make_string(void *str, int32_t size){ + String result; + result.str = (char*)str; + result.size = size; + result.memory_size = size; + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +str_size(char *str) +{ + int32_t i = 0; + while (str[i]) ++i; + return i; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +make_string_slowly(void *str) +{ + String result; + result.str = (char*)str; + result.size = str_size((char*)str); + result.memory_size = result.size; + return result; +} +#endif + +// TODO(allen): I don't love the substr rule, I chose +// substr(String, start) and substr(String, start, size) +// but I wish I had substr(String, start) and substr(String, start, end) + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +substr(String str, int32_t start) +{ + String result; + result.str = str.str + start; + result.size = str.size - start; + result.memory_size = 0; + return(result); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +substr_start_size(String str, int32_t start, int32_t size) +{ + String result; + result.str = str.str + start; + result.size = size; + if (start + size > str.size){ + result.size = str.size - start; + } + result.memory_size = 0; + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK String +skip_whitespace(String str) +{ + String result = {0}; + int32_t i = 0; + for (; i < str.size && char_is_whitespace(str.str[i]); ++i); + result = substr_start_size(str, i, str.size - i); + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK String +chop_whitespace(String str) +{ + String result = {0}; + int32_t i = str.size; + for (; i > 0 && char_is_whitespace(str.str[i-1]); --i); + result = substr_start_size(str, 0, i); + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK String +skip_chop_whitespace(String str) +{ + str = skip_whitespace(str); + str = chop_whitespace(str); + return(str); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +tailstr(String str) +{ + String result; + result.str = str.str + str.size; + result.memory_size = str.memory_size - str.size; + result.size = 0; + return(result); +} +#endif + + +// +// String Comparison +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_cc(char *a, char *b){ + for (int32_t i = 0;; ++i){ + if (a[i] != b[i]){ + return 0; + } + if (a[i] == 0){ + return 1; + } + } +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_sc(String a, char *b){ + int32_t i = 0; + for (; i < a.size; ++i){ + if (a.str[i] != b[i]){ + return 0; + } + } + if (b[i] != 0){ + return 0; + } + return 1; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_cs(char *a, String b){ + return(match_sc(b,a)); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_ss(String a, String b){ + if (a.size != b.size){ + return 0; + } + for (int32_t i = 0; i < b.size; ++i){ + if (a.str[i] != b.str[i]){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_ccl(char *a, char *b, int32_t *len){ + int32_t i; + for (i = 0; b[i] != 0; ++i){ + if (a[i] != b[i]){ + return 0; + } + } + *len = i; + return 1; +} +#endif + + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_scl(String a, char *b, int32_t *len){ + int32_t i; + for (i = 0; b[i] != 0; ++i){ + if (a.str[i] != b[i] || i == a.size){ + return 0; + } + } + *len = i; + return 1; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_part_cc(char *a, char *b){ + int32_t x; + return match_part_ccl(a,b,&x); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_part_sc(String a, char *b){ + int32_t x; + return match_part_scl(a,b,&x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_cs(char *a, String b){ + for (int32_t i = 0; i != b.size; ++i){ + if (a[i] != b.str[i]){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_ss(String a, String b){ + if (a.size < b.size){ + return 0; + } + for (int32_t i = 0; i < b.size; ++i){ + if (a.str[i] != b.str[i]){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_insensitive_cc(char *a, char *b){ + for (int32_t i = 0;; ++i){ + if (char_to_upper(a[i]) != + char_to_upper(b[i])){ + return 0; + } + if (a[i] == 0){ + return 1; + } + } +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_insensitive_sc(String a, char *b){ + int32_t i = 0; + for (; i < a.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b[i])){ + return 0; + } + } + if (b[i] != 0){ + return 0; + } + return 1; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_insensitive_cs(char *a, String b){ + return match_insensitive_sc(b,a); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_insensitive_ss(String a, String b){ + if (a.size != b.size){ + return 0; + } + for (int32_t i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != + char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_insensitive_ccl(char *a, char *b, int32_t *len){ + int32_t i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b[i])){ + return 0; + } + } + *len = i; + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_insensitive_scl(String a, char *b, int32_t *len){ + int32_t i; + for (i = 0; b[i] != 0; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b[i]) || + i == a.size){ + return 0; + } + } + *len = i; + return 1; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_part_insensitive_cc(char *a, char *b){ + int32_t x; + return match_part_ccl(a,b,&x); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +match_part_insensitive_sc(String a, char *b){ + int32_t x; + return match_part_scl(a,b,&x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_insensitive_cs(char *a, String b){ + for (int32_t i = 0; i != b.size; ++i){ + if (char_to_upper(a[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +match_part_insensitive_ss(String a, String b){ + if (a.size < b.size){ + return 0; + } + for (int32_t i = 0; i < b.size; ++i){ + if (char_to_upper(a.str[i]) != char_to_upper(b.str[i])){ + return 0; + } + } + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +compare_cc(char *a, char *b){ + int32_t i = 0; + while (a[i] == b[i] && a[i] != 0){ + ++i; + } + return (a[i] > b[i]) - (a[i] < b[i]); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +compare_sc(String a, char *b){ + int32_t i = 0; + while (i < a.size && a.str[i] == b[i]){ + ++i; + } + if (i < a.size){ + return (a.str[i] > b[i]) - (a.str[i] < b[i]); + } + else{ + if (b[i] == 0){ + return 0; + } + else{ + return -1; + } + } +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE int32_t +compare_cs(char *a, String b){ + return -compare_sc(b,a); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +compare_ss(String a, String b){ + int32_t i = 0; + while (i < a.size && i < b.size && a.str[i] == b.str[i]){ + ++i; + } + if (i < a.size && i < b.size){ + return (a.str[i] > b.str[i]) - (a.str[i] < b.str[i]); + } + else{ + return (a.size > b.size) - (a.size < b.size); + } +} +#endif + +// +// Finding Characters and Substrings +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_c(char *str, int32_t start, char character){ + int32_t i = start; + while (str[i] != character && str[i] != 0) ++i; + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_s(String str, int32_t start, char character){ + int32_t i = start; + while (i < str.size && str.str[i] != character) ++i; + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_chars_c(char *str, int32_t start, char *characters){ + int32_t i = start, j; + while (str[i] != 0){ + for (j = 0; characters[j]; ++j){ + if (str[i] == characters[j]){ + return i; + } + } + ++i; + } + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_chars_s(String str, int32_t start, char *characters){ + int32_t i = start, j; + while (i < str.size){ + for (j = 0; characters[j]; ++j){ + if (str.str[i] == characters[j]){ + return i; + } + } + ++i; + } + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_substr_c(char *str, int32_t start, String seek){ + int32_t i, j, k; + fstr_bool hit; + + if (seek.size == 0){ + return str_size(str); + } + for (i = start; str[i]; ++i){ + if (str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_substr_s(String str, int32_t start, String seek){ + int32_t stop_at, i, j, k; + fstr_bool hit; + + if (seek.size == 0){ + return str.size; + } + stop_at = str.size - seek.size + 1; + for (i = start; i < stop_at; ++i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str.str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return str.size; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +rfind_substr(String str, int32_t start, String seek){ + int32_t i, j, k; + fstr_bool hit; + + if (seek.size == 0){ + return -1; + } + if (start + seek.size > str.size){ + start = str.size - seek.size; + } + for (i = start; i >= 0; --i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + if (str.str[k] != seek.str[j]){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return -1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_substr_insensitive_c(char *str, int32_t start, String seek){ + int32_t i, j, k; + fstr_bool hit; + char a_upper, b_upper; + + if (seek.size == 0){ + return str_size(str); + } + for (i = start; str[i]; ++i){ + if (str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + a_upper = char_to_upper(str[k]); + b_upper = char_to_upper(seek.str[j]); + if (a_upper != b_upper){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return i; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +find_substr_insensitive_s(String str, int32_t start, String seek){ + int32_t i, j, k; + int32_t stop_at; + fstr_bool hit; + char a_upper, b_upper; + + if (seek.size == 0){ + return str.size; + } + stop_at = str.size - seek.size + 1; + for (i = start; i < stop_at; ++i){ + if (str.str[i] == seek.str[0]){ + hit = 1; + for (j = 1, k = i+1; j < seek.size; ++j, ++k){ + a_upper = char_to_upper(str.str[k]); + b_upper = char_to_upper(seek.str[j]); + if (a_upper != b_upper){ + hit = 0; + break; + } + } + if (hit){ + return i; + } + } + } + return str.size; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +has_substr_c(char *s, String seek){ + return (s[find_substr_c(s, 0, seek)] != 0); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +has_substr_s(String s, String seek){ + return (find_substr_s(s, 0, seek) < s.size); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +has_substr_insensitive_c(char *s, String seek){ + return (s[find_substr_insensitive_c(s, 0, seek)] != 0); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +has_substr_insensitive_s(String s, String seek){ + return (find_substr_insensitive_s(s, 0, seek) < s.size); +} +#endif + +// +// String Copies and Appends +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +copy_fast_unsafe_cc(char *dest, char *src){ + char *start = dest; + while (*src != 0){ + *dest = *src; + ++dest; + ++src; + } + return (int32_t)(dest - start); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +copy_fast_unsafe_cs(char *dest, String src){ + int32_t i = 0; + while (i != src.size){ + dest[i] = src.str[i]; + ++i; + } + return(src.size); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +copy_checked_ss(String *dest, String src){ + char *dest_str; + int32_t i; + if (dest->memory_size < src.size){ + return 0; + } + dest_str = dest->str; + for (i = 0; i < src.size; ++i){ + dest_str[i] = src.str[i]; + } + dest->size = src.size; + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +copy_partial_sc(String *dest, char *src){ + int32_t i = 0; + int32_t memory_size = dest->memory_size; + char *dest_str = dest->str; + while (src[i] != 0){ + if (i >= memory_size){ + return 0; + } + dest_str[i] = src[i]; + ++i; + } + dest->size = i; + return 1; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +copy_partial_ss(String *dest, String src){ + char *dest_str = dest->str; + int32_t memory_size = dest->memory_size; + fstr_bool result = 0; + if (memory_size >= src.size){ + result = 1; + memory_size = src.size; + } + for (int32_t i = 0; i < memory_size; ++i){ + dest_str[i] = src.str[i]; + } + dest->size = memory_size; + return result; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE int32_t +copy_cc(char *dest, char *src){ + return copy_fast_unsafe_cc(dest, src); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE void +copy_ss(String *dest, String src){ + copy_checked_ss(dest, src); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE void +copy_sc(String *dest, char *src){ + copy_partial_sc(dest, src); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_checked_ss(String *dest, String src){ + String end = tailstr(*dest); + fstr_bool result = copy_checked_ss(&end, src); + // NOTE(allen): This depends on end.size still being 0 if + // the check failed and no coppy occurred. + dest->size += end.size; + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_partial_sc(String *dest, char *src){ + String end = tailstr(*dest); + fstr_bool result = copy_partial_sc(&end, src); + dest->size += end.size; + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_partial_ss(String *dest, String src){ + String end = tailstr(*dest); + fstr_bool result = copy_partial_ss(&end, src); + dest->size += end.size; + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_char(String *dest, char c){ + fstr_bool result = 0; + if (dest->size < dest->memory_size){ + dest->str[dest->size++] = c; + result = 1; + } + return result; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +append_ss(String *dest, String src){ + return append_partial_ss(dest, src); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE fstr_bool +append_sc(String *dest, char *src){ + return append_partial_sc(dest, src); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +terminate_with_null(String *str){ + fstr_bool result = 0; + if (str->size < str->memory_size){ + str->str[str->size] = 0; + result = 1; + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_padding(String *dest, char c, int32_t target_size){ + fstr_bool result = 1; + int32_t offset = target_size - dest->size; + int32_t r = 0; + if (offset > 0){ + for (r = 0; r < offset; ++r){ + if (append_char(dest, c) == 0){ + result = 0; + break; + } + } + } + return(result); +} +#endif + + +// +// Other Edits +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK void +replace_char(String *str, char replace, char with){ + char *s = str->str; + int32_t i = 0; + for (i = 0; i < str->size; ++i, ++s){ + if (*s == replace) *s = with; + } +} +#endif + +// +// String <-> Number Conversions +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +int_to_str_size(int32_t x){ + int32_t size = 1; + if (x < 0){ + size = 2; + } + x /= 10; + while (x != 0){ + x /= 10; + ++size; + } + return(size); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +int_to_str(String *dest, int32_t x){ + fstr_bool result = 1; + char *str = dest->str; + int32_t memory_size = dest->memory_size; + int32_t size, i, j; + fstr_bool negative; + + if (x == 0){ + str[0] = '0'; + dest->size = 1; + } + else{ + size = 0; + negative = 0; + if (x < 0){ + negative = 1; + x = -x; + str[size++] = '-'; + } + while (x != 0){ + if (size == memory_size){ + result = 0; + break; + } + i = x % 10; + x /= 10; + str[size++] = (char)('0' + i); + } + if (result){ + // NOTE(allen): Start i = 0 if not negative, start i = 1 if is negative + // because - should not be flipped if it is negative :) + for (i = negative, j = size-1; i < j; ++i, --j){ + char temp = str[i]; + str[i] = str[j]; + str[j] = temp; + } + dest->size = size; + } + else{ + dest->size = 0; + } + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_int_to_str(String *dest, int32_t x){ + String last_part = tailstr(*dest); + fstr_bool result = int_to_str(&last_part, x); + if (result){ + dest->size += last_part.size; + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +u64_to_str_size(uint64_t x){ + int32_t size; + if (x < 0){ + size = 0; + } + else{ + size = 1; + x /= 10; + while (x != 0){ + x /= 10; + ++size; + } + } + return(size); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +u64_to_str(String *dest, uint64_t x){ + fstr_bool result = 1; + char *str = dest->str; + int32_t memory_size = dest->memory_size; + int32_t size, i, j; + + if (x == 0){ + str[0] = '0'; + dest->size = 1; + } + else{ + size = 0; + while (x != 0){ + if (size == memory_size){ + result = 0; + break; + } + i = x % 10; + x /= 10; + str[size++] = (char)('0' + i); + } + if (result){ + for (i = 0, j = size-1; i < j; ++i, --j){ + char temp = str[i]; + str[i] = str[j]; + str[j] = temp; + } + dest->size = size; + } + else{ + dest->size = 0; + } + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_u64_to_str(String *dest, uint64_t x){ + String last_part = tailstr(*dest); + fstr_bool result = u64_to_str(&last_part, x); + if (result){ + dest->size += last_part.size; + } + return(result); +} +#endif + +#ifndef FSTRING_GUARD +typedef struct Float_To_Str_Variables{ + fstr_bool negative; + int32_t int_part; + int32_t dec_part; +} Float_To_Str_Variables; + +Float_To_Str_Variables +get_float_vars(float x){ + Float_To_Str_Variables vars = {0}; + + if (x < 0){ + vars.negative = 1; + x = -x; + } + + vars.int_part = (int32_t)(x); + vars.dec_part = (int32_t)((x - vars.int_part) * 1000); + + return(vars); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +float_to_str_size(float x){ + Float_To_Str_Variables vars = get_float_vars(x); + int32_t size = + vars.negative + int_to_str_size(vars.int_part) + 1 + int_to_str_size(vars.dec_part); + return(size); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +append_float_to_str(String *dest, float x){ + fstr_bool result = 1; + Float_To_Str_Variables vars = get_float_vars(x); + + if (vars.negative){ + append_char(dest, '-'); + } + + append_int_to_str(dest, vars.int_part); + append_char(dest, '.'); + append_int_to_str(dest, vars.dec_part); + + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +float_to_str(String *dest, float x){ + fstr_bool result = 1; + dest->size = 0; + append_float_to_str(dest, x); + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +str_is_int(String str){ + fstr_bool result = 1; + for (int32_t i = 0; i < str.size; ++i){ + if (!char_is_numeric(str.str[i])){ + result = 0; + break; + } + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +str_to_int_c(char *str){ + int32_t x = 0; + for (; *str; ++str){ + if (*str >= '0' || *str <= '9'){ + x *= 10; + x += *str - '0'; + } + else{ + x = 0; + break; + } + } + return(x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +str_to_int_s(String str){ + int32_t x, i; + if (str.size == 0){ + x = 0; + } + else{ + x = str.str[0] - '0'; + for (i = 1; i < str.size; ++i){ + x *= 10; + x += str.str[i] - '0'; + } + } + return(x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +hexchar_to_int(char c){ + int32_t x = 0; + if (c >= '0' && c <= '9'){ + x = c-'0'; + } + else if (c > 'F'){ + x = c+(10-'a'); + } + else{ + x = c+(10-'A'); + } + return(x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK char +int_to_hexchar(int32_t x){ + return (x<10)?((char)x+'0'):((char)x+'a'-10); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK uint32_t +hexstr_to_int(String str){ + uint32_t x; + int32_t i; + if (str.size == 0){ + x = 0; + } + else{ + x = hexchar_to_int(str.str[0]); + for (i = 1; i < str.size; ++i){ + x *= 0x10; + x += hexchar_to_int(str.str[i]); + } + } + return(x); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +color_to_hexstr(String *s, uint32_t color){ + fstr_bool result = 0; + int32_t i; + + if (s->memory_size == 7 || s->memory_size == 8){ + result = 1; + s->size = 6; + s->str[6] = 0; + color = color & 0x00FFFFFF; + for (i = 5; i >= 0; --i){ + s->str[i] = int_to_hexchar(color & 0xF); + color >>= 4; + } + } + else if (s->memory_size > 8){ + result = 1; + s->size = 8; + s->str[8] = 0; + for (i = 7; i >= 0; --i){ + s->str[i] = int_to_hexchar(color & 0xF); + color >>= 4; + } + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +hexstr_to_color(String s, uint32_t *out){ + fstr_bool result = 0; + uint32_t color = 0; + if (s.size == 6){ + result = 1; + color = (unsigned int)hexstr_to_int(s); + color |= (0xFF << 24); + *out = color; + } + else if (s.size == 8){ + result = 1; + color = (unsigned int)hexstr_to_int(s); + *out = color; + } + return(result); +} +#endif + +// +// Directory String Management +// + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK int32_t +reverse_seek_slash_pos(String str, int32_t pos){ + int32_t i = str.size - 1 - pos; + while (i >= 0 && !char_is_slash(str.str[i])){ + --i; + } + return i; +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE int32_t +reverse_seek_slash(String str){ + return(reverse_seek_slash_pos(str, 0)); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +front_of_directory(String dir){ + return substr(dir, reverse_seek_slash(dir) + 1); +} +#endif + +#ifndef FSTRING_GUARD +FSTRING_INLINE String +path_of_directory(String dir){ + return substr_start_size(dir, 0, reverse_seek_slash(dir) + 1); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +set_last_folder_c(String *dir, char *folder_name, char slash){ + fstr_bool result = 0; + int32_t size = reverse_seek_slash(*dir) + 1; + dir->size = size; + if (append_sc(dir, folder_name)){ + if (append_char(dir, slash)){ + result = 1; + } + } + if (!result){ + dir->size = size; + } + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +set_last_folder_s(String *dir, String folder_name, char slash){ + fstr_bool result = 0; + int32_t size = reverse_seek_slash(*dir) + 1; + dir->size = size; + if (append_ss(dir, folder_name)){ + if (append_char(dir, slash)){ + result = 1; + } + } + if (!result){ + dir->size = size; + } + return result; +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK String +file_extension(String str){ + int32_t i; + for (i = str.size - 1; i >= 0; --i){ + if (str.str[i] == '.') break; + } + ++i; + return make_string(str.str+i, str.size-i); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +remove_extension(String *str){ + fstr_bool result = 0; + char *s = str->str; + int32_t i; + for (i = str->size - 1; i >= 0; --i){ + if (s[i] == '.') break; + } + if (i >= 0){ + result = 1; + str->size = i; + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +remove_last_folder(String *str){ + fstr_bool result = 0; + int32_t end = reverse_seek_slash_pos(*str, 1); + if (end >= 0){ + result = 1; + str->size = end + 1; + } + return(result); +} +#endif + +// TODO(allen): Add hash-table extension to string sets. +#ifdef FSTRING_IMPLEMENTATION +FSTRING_LINK fstr_bool +string_set_match(String *str_set, int32_t count, String str, int32_t *match_index){ + fstr_bool result = 0; + int32_t i = 0; + for (; i < count; ++i, ++str_set){ + if (match_ss(*str_set, str)){ + *match_index = i; + result = 1; + break; + } + } + return(result); +} +#endif + +#ifdef FSTRING_IMPLEMENTATION +#undef FSTRING_IMPLEMENTATION +#endif + +#ifndef FSTRING_GUARD +#define FSTRING_GUARD +#endif + +// BOTTOM + diff --git a/test_data/lots_of_files/4tech_table.cpp b/test_data/lots_of_files/4tech_table.cpp new file mode 100644 index 0000000..e1d9280 --- /dev/null +++ b/test_data/lots_of_files/4tech_table.cpp @@ -0,0 +1,235 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 14.02.2016 + * + * 4tech C style genereic hash table + * + */ + +// TOP + +#define TableHashEmpty 0 +#define TableHashDeleted 1 +#define TableHashMin 0x10000000 + +typedef u32 Hash_Function(void *item, void *arg); +typedef i32 Compare_Function(void *key, void *item, void *arg); + +struct Table{ + u32 *hash_array; + u8 *data_array; + i32 count, max; + + i32 item_size; +}; + +internal b32 +table_at_capacity(Table *table){ + b32 result = 1; + if (table->count * 8 < table->max * 7){ + result = 0; + } + return(result); +} + +internal b32 +table_add(Table *table, void *item, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){ + u32 hash, *inspect; + i32 i; + + Assert(table->count * 8 < table->max * 7); + + hash = (hash_func(item, arg) | TableHashMin); + i = hash % table->max; + inspect = table->hash_array + i; + + while (*inspect >= TableHashMin){ + if (*inspect == hash){ + if (comp_func(item, table->data_array + i*table->item_size, arg) == 0){ + return(1); + } + } + ++i; + ++inspect; + if (i == table->max){ + i = 0; + inspect = table->hash_array; + } + } + *inspect = hash; + memcpy(table->data_array + i*table->item_size, item, table->item_size); + ++table->count; + + return(0); +} + +internal b32 +table_find_pos(Table *table, void *search_key, void *arg, i32 *pos, i32 *index, Hash_Function *hash_func, Compare_Function *comp_func){ + u32 hash, *inspect; + i32 i; + + hash = (hash_func(search_key, arg) | TableHashMin); + i = hash % table->max; + inspect = table->hash_array + i; + + while (*inspect != TableHashEmpty){ + if (*inspect == hash){ + if (comp_func(search_key, table->data_array + i*table->item_size, arg) == 0){ + if (pos) *pos = i*table->item_size; + if (index) *index = i; + return(1); + } + } + ++i; + ++inspect; + if (i == table->max){ + i = 0; + inspect = table->hash_array; + } + } + + return(0); +} + +internal void* +table_find_item(Table *table, void *search_key, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){ + i32 pos; + void *result = 0; + if (table_find_pos(table, search_key, arg, &pos, 0, hash_func, comp_func)){ + result = table->data_array + pos; + } + return(result); +} + +internal void +table_remove_index(Table *table, i32 index){ + table->hash_array[index] = TableHashDeleted; + --table->count; +} + +internal b32 +table_remove_match(Table *table, void *search_key, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){ + i32 index; + b32 result = 0; + if (table_find_pos(table, search_key, arg, 0, &index, hash_func, comp_func)){ + table_remove_index(table, index); + result = 1; + } + return(result); +} + +internal void +table_clear(Table *table){ + table->count = 0; + memset(table->hash_array, 0, table->max*sizeof(*table->hash_array)); +} + +internal void +table_rehash(Table *src, Table *dst, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){ + i32 i, c, count, item_size; + u32 *hash_item; + u8 *data_item; + + Assert((dst->count + src->count - 1) * 7 < dst->max * 8); + Assert(dst->item_size == src->item_size); + + count = src->count; + hash_item = src->hash_array; + data_item = src->data_array; + item_size = src->item_size; + for (i = 0, c = 0; c < count; ++i, ++hash_item, data_item += item_size){ + if (*hash_item >= TableHashMin){ + ++c; + table_add(dst, data_item, arg, hash_func, comp_func); + } + } +} + +internal u32 +tbl_string_hash(void *item, void *arg){ + String *string = (String*)item; + char *str; + i32 i,len; + u32 x = 5381; + char c; + (void)arg; + + str = string->str; + len = string->size; + i = 0; + while (i < len){ + c = str[i++]; + x = ((x << 5) + x) + c; + } + + return(x); +} + +internal i32 +tbl_string_compare(void *a, void *b, void *arg){ + String *stra = (String*)a; + String *strb = (String*)b; + i32 result = !match(*stra, *strb); + return(result); +} + +internal u32 +tbl_offset_string_hash(void *item, void *arg){ + Offset_String *string = (Offset_String*)item; + char *str; + i32 i,len; + u32 x = 5381; + char c; + + str = ((char*)arg) + string->offset; + len = string->size; + i = 0; + while (i < len){ + c = str[i++]; + x = ((x << 5) + x) + c; + } + + return(x); +} + +internal i32 +tbl_offset_string_compare(void *a, void *b, void *arg){ + Offset_String *ostra = (Offset_String*)a; + Offset_String *ostrb = (Offset_String*)b; + String stra = make_string((char*)arg + ostra->offset, ostra->size); + String strb = make_string((char*)arg + ostrb->offset, ostrb->size); + i32 result = !match(stra, strb); + return(result); +} + +struct String_Space{ + char *space; + i32 pos, new_pos, max; +}; + +internal Offset_String +strspace_append(String_Space *space, char *str, i32 len){ + Offset_String result = {}; + if (space->new_pos + len <= space->max){ + result.offset = space->new_pos; + result.size = len; + + memcpy(space->space + space->new_pos, str, len); + space->new_pos = space->pos + len; + } + return(result); +} + +internal void +strspace_keep_prev(String_Space *space){ + space->pos = space->new_pos; +} + +internal void +strspace_discard_prev(String_Space *space){ + space->new_pos = space->pos; +} + +// BOTTOM + diff --git a/test_data/lots_of_files/Agent.cpp b/test_data/lots_of_files/Agent.cpp new file mode 100644 index 0000000..cced404 --- /dev/null +++ b/test_data/lots_of_files/Agent.cpp @@ -0,0 +1,424 @@ +// ==++== +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ==--== +// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +// +// Agent.cpp +// +// Source file containing code for the agent creation APIs. +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +#include "concrtinternal.h" +#include <agents.h> + +namespace Concurrency +{ + +// A Filter function for a filter_block to check if the Agent has completed +bool _IsDone(agent_status const &status) +{ + return status == agent_done || status == agent_canceled; +} + +// A Filter function for a filter_block to check if the Agent has started (or completed) +bool _IsStarted(agent_status const &status) +{ + return _IsDone(status) || status == agent_started; +} + +/// <summary> +/// Creates an agent within the default scheduler, and places it any schedule +/// group of the scheduler's choosing. +/// </summary> +agent::agent() : + _M_fStartable(TRUE), _M_fCancelable(TRUE), _M_pScheduler(NULL), _M_pScheduleGroup(NULL) +{ + _Trace_agents(AGENTS_EVENT_CREATE, + details::_Trace_agents_get_id(this), + details::_Trace_agents_get_id(this)); + + send<agent_status> (_M_status, agent_created); +} + +/// <summary> +/// Create an agent within the specified scheduler, in a schedule group of the +/// scheduler's choosing. +/// </summary> +agent::agent(Scheduler& pScheduler) : + _M_fStartable(TRUE), _M_fCancelable(TRUE), _M_pScheduler(&pScheduler), _M_pScheduleGroup(NULL) +{ + _Trace_agents(AGENTS_EVENT_CREATE, + details::_Trace_agents_get_id(this), + details::_Trace_agents_get_id(this)); + + send<agent_status> (_M_status, agent_created); +} + +/// <summary> +/// Create an agent within the specified schedule group. The scheduler is implied +/// by the schedule group. +/// </summary> +agent::agent(ScheduleGroup& pGroup) : + _M_fStartable(TRUE), _M_fCancelable(TRUE), _M_pScheduler(NULL), _M_pScheduleGroup(&pGroup) +{ + _Trace_agents(AGENTS_EVENT_CREATE, + details::_Trace_agents_get_id(this), + details::_Trace_agents_get_id(this)); + + send<agent_status> (_M_status, agent_created); +} + +/// <summary> +/// Cleans up any resources that may have been created by the Agent. +/// </summary> +agent::~agent() +{ + _Trace_agents(AGENTS_EVENT_DESTROY, details::_Trace_agents_get_id(this)); +} + +/// <returns> +/// Returns a message source that can pass messages about the current state of the agent +/// </returns> +ISource<agent_status> * agent::status_port() +{ + return &_M_status; +} + +/// <returns> +/// Returns the current state of the agent. Note that this returned state could change +/// immediately after being returned. +/// </returns> +agent_status agent::status() +{ + return receive<agent_status>(_M_status); +} + +/// <summary> +/// Moves an Agent from the agent_created state to the agent_runnable state, and schedules it for execution. +/// </summary> +/// <returns> +/// true if the agent started correctly, false otherwise +/// </returns> +bool agent::start() +{ + if(_M_status.value() != agent_created) + { + return false; + } + + // + // Check if the agent is Startable. If the agent had already called start() or + // this variable was set to FALSE in cancel(), return false. + // + if(InterlockedCompareExchange(&_M_fStartable, FALSE, TRUE) == FALSE) + { + return false; + } + + _Trace_agents(AGENTS_EVENT_SCHEDULE, details::_Trace_agents_get_id(this)); + send<agent_status> (_M_status, agent_runnable); + + TaskProc proc = &Concurrency::agent::_Agent_task_wrapper; + if(_M_pScheduleGroup != NULL) + { + _M_pScheduleGroup->ScheduleTask(proc, this); + } + else if(_M_pScheduler != NULL) + { + _M_pScheduler->ScheduleTask(proc, this); + } + else + { + CurrentScheduler::ScheduleTask(proc, this); + } + + return true; +} + +/// <summary> +/// Moves an agent into the done state, indicating the completion of the agent +/// </summary> +/// <returns> +/// true if the agent is moved to the agent_done state, false otherwise +/// </returns> +bool agent::done() +{ + // + // current status + // + agent_status currentStatus = this->status(); + + // + // Indicate that the agent can no longer be started. + // + if (InterlockedCompareExchange(&_M_fStartable, FALSE, TRUE) != TRUE) + { + // + // agent is either canceled, started or completed run. + // + currentStatus = receive<agent_status>(_M_status, _IsStarted); + } + + // + // Agent is not cancelable anymore. + // + InterlockedExchange(&_M_fCancelable, FALSE); + + // + // Transition to agent_done state if it not already in one of + // the terminal states. + // + if ((currentStatus != agent_canceled) && (currentStatus != agent_done)) + { + send<agent_status> (_M_status, agent_done); + + return true; + } + + return false; +} + +/// <summary> +/// Moves an agent from the agent_created or agent_runnable to the agent_canceled state. +/// </summary> +/// <returns> +/// true if the agent was canceled correctly, false otherwise +/// </returns> +bool agent::cancel() +{ + // + // In case this agent has been canceled before it was even started + // mark it as no longer Startable and send a agent_canceled message to the + // status port + // + if(InterlockedCompareExchange(&_M_fStartable, FALSE, TRUE) == TRUE) + { + send<agent_status> (_M_status, agent_canceled); + } + + // + // Check to see if the agent is still Cancelable. Agents are initialized + // m_fCancelable == TRUE, and set to false either here in cancel(), so + // cancel() will not be called twice, or in the LWT, once the execution + // of the Agent task has begun. + // + if(InterlockedCompareExchange(&_M_fCancelable, FALSE, TRUE) == TRUE) + { + // Wait for the agent to reach a canceled state state + receive<agent_status>(_M_status, _IsDone); + + // The above InterlockedCompareExchange marked this agent for cancelation + // When the LWT that has been spun up tries to execute the task, it will + // find it has been canceled and will propagate out the canceled state to + // the state buffer. + return true; + } + + return false; +} + + +// Private helper class to order an input array of agents. This is used by +// wait_for_all and wait_for_one to create an array of appropriate order nodes. +// The template _OrderNode specifies an _Order_node_base that accepts agent_status. +// For example, _Reserving_node<agent_status> +template<class _OrderNode> +class _OrderBlock +{ +public: + + // Constructs an orderBlock which has an array of ordernodes connected to the agents. + // The ordernodes are given a filter method to filter out non-terminal agent states + _OrderBlock(size_t _Count, agent ** _PAgents, ITarget<size_t> * _PTarget) : _M_count(_Count) + { + // Create an array of order nodes + _M_ppNodes = _concrt_new _OrderNode*[_M_count]; + for (size_t i = 0; i < _M_count; i++) + { + _M_ppNodes[i] = _concrt_new _OrderNode(_PAgents[i]->status_port(), i, _PTarget, _IsDone); + } + } + + // Destroys the block + ~_OrderBlock() + { + for (size_t i = 0; i < _M_count; i++) + { + delete _M_ppNodes[i]; + } + + delete [] _M_ppNodes; + } + + // Retrieve the agent status for the agent at the given index + agent_status _Status(size_t _Index) + { + _CONCRT_ASSERT(_M_ppNodes[_Index]->has_value()); + + return _M_ppNodes[_Index]->value(); + } + +private: + + // Number of order nodes + size_t _M_count; + + // Array of order nodes + _OrderNode ** _M_ppNodes; +}; + + +/// <summary> +/// Wait for an agent to complete its task. A task is completed when it enters the agent_canceled, +/// or agent_done states. +/// </summary> +agent_status agent::wait(agent * pAgent, unsigned int timeout) +{ + if(pAgent == NULL) + { + throw std::invalid_argument("pAgent"); + } + + return receive<agent_status>(pAgent->status_port(), _IsDone, timeout); +} + +/// <summary> +/// Wait for all agents in a given Agent array to complete their tasks. A task is completed +/// when it enters the agent_canceled or agent_done states. +/// </summary> +void agent::wait_for_all(size_t count, agent ** pAgents, agent_status * pStatus, unsigned int timeout) +{ + if ( pAgents == NULL ) + { + throw std::invalid_argument("pAgents"); + } + + for (size_t i = 0; i < count; i++) + { + if ( pAgents[i] == NULL ) + { + throw std::invalid_argument("pAgents"); + } + } + + // Create the following network + // + // agent - orderNode - + // \ + // agent - orderNode - --call ~~~ single_assignment + // / + // agent - orderNode - + + single_assignment<size_t> _Sa; + volatile size_t _CompletedAgents = 0; + call<size_t> _Call([&](size_t const& _Index) + { + // Safe to access without synchronization since call blocks + // guarantee that the function is not called for multiple + // messages at the same time. + _CONCRT_ASSERT(_CompletedAgents < count); + if (++_CompletedAgents == count) + { + // All the agents have completed. Indicate the same by sending a message + // (initialize) to the single assignment. + send<size_t>(_Sa, 1); + } + }); + + _OrderBlock<_Greedy_node<agent_status>> _OrderedAgents(count, pAgents, &_Call); + + receive(&_Sa, timeout); + + // single_assignment has a message => all agents completed + // Retrieve their status messages. + if(pStatus != NULL) + { + for (size_t i = 0; i < count; i++) + { + pStatus[i] = _OrderedAgents._Status(i); + } + } +} + +/// <summary> +/// Wait for any one of the agents in a given AgentTask array to complete its task. A task is completed +/// when it enters the agent_canceled or agent_done states. +/// </summary> +void agent::wait_for_one(size_t count, agent ** pAgents, agent_status &status, size_t& index, unsigned int timeout) +{ + if ( pAgents == NULL ) + { + throw std::invalid_argument("pAgents"); + } + + for (size_t i = 0; i < count; i++) + { + if ( pAgents[i] == NULL ) + { + throw std::invalid_argument("pAgents"); + } + } + + // Create the following network + // + // agent - orderNode - + // \ + // agent - orderNode - --single_assignment + // / + // agent - orderNode - + + single_assignment<size_t> _Sa; + _OrderBlock<_Greedy_node<agent_status>> _OrderedAgents(count, pAgents, &_Sa); + + index = receive(&_Sa, timeout); + + // We were able to receive the index. Get the message (agent_status) + status = _OrderedAgents._Status(index); +} + +// A static wrapper function that calls the Run() method. Used for scheduling of the task +void agent::_Agent_task_wrapper(void* data) +{ + agent *pAgent = (agent *) data; + + if(InterlockedCompareExchange(&pAgent->_M_fCancelable, FALSE, TRUE) == TRUE) + { + send<agent_status> (pAgent->_M_status, agent_started); + + // Invoke the run() function of the agent. + _Trace_agents(AGENTS_EVENT_START, details::_Trace_agents_get_id(pAgent)); + pAgent->run(); + _Trace_agents(AGENTS_EVENT_END, details::_Trace_agents_get_id(pAgent), 0); + } + else + { + // This else path can be entered only if an agent was canceled before it + // ran. Send a agent_canceled message to the status. + send<agent_status> (pAgent->_M_status, agent_canceled); + } +} + +// Implementation of agent APIs that should not be publicly exposed + +namespace details +{ + static volatile runtime_object_identity s_RuntimeObjectIdentity = 0; + + _CRTIMP2 _Runtime_object::_Runtime_object() + { + // Increment the id by 2. This is done because certain blocks (like join) need to have + // a special message id to indicate a NULL id. In this case, we use -1. Incrementing by 2 + // will avoid any wrap-around issues causing us to hit -1. + runtime_object_identity id = InterlockedExchangeAdd((volatile long *) &s_RuntimeObjectIdentity, 2); + _CONCRT_ASSERT(id != -1); + _M_id = id; + } + + _CRTIMP2 _Runtime_object::_Runtime_object(runtime_object_identity _Id) : _M_id(_Id) + { + } +} // namespace details +} // namespace Concurrency diff --git a/test_data/lots_of_files/Base64.cpp b/test_data/lots_of_files/Base64.cpp new file mode 100644 index 0000000..0074860 --- /dev/null +++ b/test_data/lots_of_files/Base64.cpp @@ -0,0 +1,219 @@ +#include "Base64.h" + +#include <cmath> +#include <cstring> +#include <string> + +/** + * characters used for Base64 encoding + */ +const char *BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + +/** + * encode three bytes using base64 (RFC 3548) + * + * @param triple three bytes that should be encoded + * @param result buffer of four characters where the result is stored + */ +void _base64_encode_triple(unsigned char triple[3], char result[4]) +{ + int tripleValue, i; + + tripleValue = triple[0]; + tripleValue *= 256; + tripleValue += triple[1]; + tripleValue *= 256; + tripleValue += triple[2]; + + for (i=0; i<4; i++) + { + result[3-i] = BASE64_CHARS[tripleValue%64]; + tripleValue /= 64; + } +} + +/** + * encode an array of bytes using Base64 (RFC 3548) + * + * @param source the source buffer + * @param sourcelen the length of the source buffer + * @param target the target buffer + * @param targetlen the length of the target buffer + * @return 1 on success, 0 otherwise + */ +int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen) +{ + /* check if the result will fit in the target buffer */ + if ((sourcelen+2)/3*4 > targetlen-1) + return 0; + + /* encode all full triples */ + while (sourcelen >= 3) + { + _base64_encode_triple(source, target); + sourcelen -= 3; + source += 3; + target += 4; + } + + /* encode the last one or two characters */ + if (sourcelen > 0) + { + unsigned char temp[3]; + memset(temp, 0, sizeof(temp)); + memcpy(temp, source, sourcelen); + _base64_encode_triple(temp, target); + target[3] = '='; + if (sourcelen == 1) + target[2] = '='; + + target += 4; + } + + /* terminate the string */ + target[0] = 0; + + return 1; +} + +/** + * determine the value of a base64 encoding character + * + * @param base64char the character of which the value is searched + * @return the value in case of success (0-63), -1 on failure + */ +int _base64_char_value(char base64char) +{ + if (base64char >= 'A' && base64char <= 'Z') + return base64char-'A'; + if (base64char >= 'a' && base64char <= 'z') + return base64char-'a'+26; + if (base64char >= '0' && base64char <= '9') + return base64char-'0'+2*26; + if (base64char == '-') + return 2*26+10; + if (base64char == '_') + return 2*26+11; + return -1; +} + +/** + * decode a 4 char base64 encoded byte triple + * + * @param quadruple the 4 characters that should be decoded + * @param result the decoded data + * @return length of the result (1, 2 or 3), 0 on failure + */ +int _base64_decode_triple(char quadruple[4], unsigned char *result) +{ + int i, triple_value, bytes_to_decode = 3, only_equals_yet = 1; + int char_value[4]; + + for (i=0; i<4; i++) + char_value[i] = _base64_char_value(quadruple[i]); + + /* check if the characters are valid */ + for (i=3; i>=0; i--) + { + if (char_value[i]<0) + { + if (only_equals_yet && quadruple[i]=='=') + { + /* we will ignore this character anyway, make it something + * that does not break our calculations */ + char_value[i]=0; + bytes_to_decode--; + continue; + } + return 0; + } + /* after we got a real character, no other '=' are allowed anymore */ + only_equals_yet = 0; + } + + /* if we got "====" as input, bytes_to_decode is -1 */ + if (bytes_to_decode < 0) + bytes_to_decode = 0; + + /* make one big value out of the partial values */ + triple_value = char_value[0]; + triple_value *= 64; + triple_value += char_value[1]; + triple_value *= 64; + triple_value += char_value[2]; + triple_value *= 64; + triple_value += char_value[3]; + + /* break the big value into bytes */ + for (i=bytes_to_decode; i<3; i++) + triple_value /= 256; + for (i=bytes_to_decode-1; i>=0; i--) + { + result[i] = triple_value%256; + triple_value /= 256; + } + + return bytes_to_decode; +} + +/** + * decode base64 encoded data + * + * @param source the encoded data (zero terminated) + * @param target pointer to the target buffer + * @param targetlen length of the target buffer + * @return length of converted data on success, -1 otherwise + */ +size_t base64_decode(const char *source, unsigned char *target, size_t targetlen) +{ + char *src, *tmpptr; + char quadruple[4]; + unsigned char tmpresult[3]; + int i; + size_t tmplen = 3; + size_t converted = 0; + + /* concatenate '===' to the source to handle unpadded base64 data */ + src = (char *)malloc(strlen(source)+5); + if (src == NULL) + return -1; + strcpy(src, source); + strcat(src, "===="); + tmpptr = src; + + /* convert as long as we get a full result */ + while (tmplen == 3) + { + /* get 4 characters to convert */ + for (i=0; i<4; i++) + { + /* skip invalid characters - we won't reach the end */ + while (*tmpptr != '=' && _base64_char_value(*tmpptr)<0) + tmpptr++; + + quadruple[i] = *(tmpptr++); + } + + /* convert the characters */ + tmplen = _base64_decode_triple(quadruple, tmpresult); + + /* check if the fit in the result buffer */ + if (targetlen < tmplen) + { + free(src); + return -1; + } + + /* put the partial result in the result buffer */ + memcpy(target, tmpresult, tmplen); + target += tmplen; + targetlen -= tmplen; + converted += tmplen; + } + + free(src); + return converted; +} + +/** get memory consumption */ +size_t base64_needed(const size_t &iSize) {return 4*size_t(floorf((float(iSize)+2.0f)/3.0f))+1;} \ No newline at end of file diff --git a/test_data/lots_of_files/Base64.h b/test_data/lots_of_files/Base64.h new file mode 100644 index 0000000..7aac130 --- /dev/null +++ b/test_data/lots_of_files/Base64.h @@ -0,0 +1,62 @@ +#pragma once +#ifndef _BASE64_H_ +#define _BASE64_H_ + + +#define _HAS_EXCEPTIONS (0) +#define _CRT_SECURE_NO_WARNINGS + +#include <cstdlib> + + +/** + * encode three bytes using base64 (RFC 3548) + * + * @param triple three bytes that should be encoded + * @param result buffer of four characters where the result is stored + */ +void _base64_encode_triple(unsigned char triple[3], char result[4]); + +/** + * encode an array of bytes using Base64 (RFC 3548) + * + * @param source the source buffer + * @param sourcelen the length of the source buffer + * @param target the target buffer + * @param targetlen the length of the target buffer + * @return 1 on success, 0 otherwise + */ +int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen); + +/** + * determine the value of a base64 encoding character + * + * @param base64char the character of which the value is searched + * @return the value in case of success (0-63), -1 on failure + */ +int _base64_char_value(char base64char); + +/** + * decode a 4 char base64 encoded byte triple + * + * @param quadruple the 4 characters that should be decoded + * @param result the decoded data + * @return length of the result (1, 2 or 3), 0 on failure + */ +int _base64_decode_triple(char quadruple[4], unsigned char *result); + +/** + * decode base64 encoded data + * + * @param source the encoded data (zero terminated) + * @param target pointer to the target buffer + * @param targetlen length of the target buffer + * @return length of converted data on success, -1 otherwise + */ +size_t base64_decode(const char *source, unsigned char *target, size_t targetlen); + +/** get memory consumption */ +size_t base64_needed(const size_t &iSize); + + +#endif \ No newline at end of file diff --git a/test_data/lots_of_files/CacheLocalScheduleGroup.cpp b/test_data/lots_of_files/CacheLocalScheduleGroup.cpp new file mode 100644 index 0000000..f0e65cd --- /dev/null +++ b/test_data/lots_of_files/CacheLocalScheduleGroup.cpp @@ -0,0 +1,104 @@ +// ==++== +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ==--== +// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +// +// CacheLocalScheduleGroup.cpp +// +// Implementation file for CacheLocalScheduleGroup. +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +#include "concrtinternal.h" + +namespace Concurrency +{ +namespace details +{ + /// <summary> + /// Puts a runnable context into the runnables collection in the schedule group. + /// </summary> + void CacheLocalScheduleGroupSegment::AddToRunnablesCollection(InternalContextBase* pContext) + { + m_runnableContexts.Enqueue(pContext); + } + + /// <summary> + /// Places a chore in the mailbox associated with this schedule group segment. + /// </summary> + /// <param name="pChore"> + /// The chore to mail. + /// </param> + /// <returns> + /// The mailbox slot into which the chore was placed. + /// </returns> + /// <remarks> + /// A mailed chore should also be placed on its regular work stealing queue. The mailing must come first and once mailed, the chore body + /// cannot be referenced until the slot is successfully claimed via a call to the ClaimSlot method. + /// </remarks> + Mailbox<_UnrealizedChore>::Slot CacheLocalScheduleGroupSegment::MailChore(_UnrealizedChore *pChore) + { + // + // There are two possible segments to which pChore can be accounted. One is the segment where it will appear on the WSQ -- the other is + // the segment where it will appear on the mailbox. Both are in the same group and hence we do not at present have reference counting + // issues. It will be attributed to the group it was picked up from which will further honor that affinity if the task blocks, etc... + // + ASSERT(!m_affinity._Is_system()); + Mailbox<_UnrealizedChore>::Slot affinitySlot = m_mailedTasks.Enqueue(pChore); + +#if _UMSTRACE && _CHORETRACK + OMTRACE(MTRACE_EVT_CHOREMAILED, this, SchedulerBase::FastCurrentContext(), NULL, pChore); + OMTRACE(MTRACE_EVT_CHOREMAILED, m_pOwningGroup, SchedulerBase::FastCurrentContext(), NULL, pChore); +#endif // _UMSTRACE && _CHORETRACK + + ASSERT(!affinitySlot.IsEmpty()); + return affinitySlot; + } + + /// <summary> + /// Notifies virtual processors that work affinitized to them has become available in the schedule group segment. + /// </summary> + void CacheLocalScheduleGroupSegment::NotifyAffinitizedWork() + { + SchedulerBase *pScheduler = m_pOwningGroup->GetScheduler(); + pScheduler->PostAffinityMessage(m_affinitySet); + + // + // If this item qualifies for the quick cache, stash it. + // + if (m_affinity._GetType() == location::_ExecutionResource) + { + pScheduler->SetQuickCacheSlot(m_maskIdIf, this); + } + } + + /// <summary> + /// Places a chore in a mailbox associated with the schedule group which is biased towards tasks being picked up from the specified + /// location. + /// </summary> + /// <param name="pChore"> + /// The chore to mail. + /// </param> + /// <param name="pPlacement"> + /// A pointer to a location where the chore will be mailed. + /// </param> + /// <returns> + /// The mailbox slot into which the chore was placed. + /// </returns> + /// <remarks> + /// A mailed chore should also be placed on its regular work stealing queue. The mailing must come first and once mailed, the chore body + /// cannot be referenced until the slot is successfully claimed via a call to the ClaimSlot method. + /// </remarks> + Mailbox<_UnrealizedChore>::Slot CacheLocalScheduleGroup::MailChore(_UnrealizedChore * pChore, + location * pPlacement, + ScheduleGroupSegmentBase ** ppDestinationSegment) + { + CacheLocalScheduleGroupSegment * pCacheLocalSegment = static_cast<CacheLocalScheduleGroupSegment *>(LocateSegment(pPlacement, true)); + *ppDestinationSegment = pCacheLocalSegment; + return pCacheLocalSegment->MailChore(pChore); + } + +} // namespace details +} // namespace Concurrency diff --git a/test_data/lots_of_files/CacheLocalScheduleGroup.h b/test_data/lots_of_files/CacheLocalScheduleGroup.h new file mode 100644 index 0000000..f6fc89e --- /dev/null +++ b/test_data/lots_of_files/CacheLocalScheduleGroup.h @@ -0,0 +1,159 @@ +// ==++== +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ==--== +// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +// +// CacheLocalScheduleGroup.h +// +// Header file containing CacheLocalScheduleGroup related declarations. +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +#pragma once + +namespace Concurrency +{ +namespace details +{ + + class CacheLocalScheduleGroup; + + class CacheLocalScheduleGroupSegment : public ScheduleGroupSegmentBase + { + + public: + + // + // Public Methods + // + + /// <summary> + /// Constructs a cache local schedule group segment + /// </summary> + CacheLocalScheduleGroupSegment(ScheduleGroupBase *pOwningGroup, SchedulingRing *pOwningRing, location* pSegmentAffinity) : + ScheduleGroupSegmentBase(pOwningGroup, pOwningRing, pSegmentAffinity) + { + } + + /// <summary> + /// Places a chore in the mailbox associated with this schedule group segment. + /// </summary> + /// <param name="pChore"> + /// The chore to mail. + /// </param> + /// <returns> + /// The mailbox slot into which the chore was placed. + /// </returns> + /// <remarks> + /// A mailed chore should also be placed on its regular work stealing queue. The mailing must come first and once mailed, the chore body + /// cannot be referenced until the slot is successfully claimed via a call to the ClaimSlot method. + /// </remarks> + Mailbox<_UnrealizedChore>::Slot MailChore(_UnrealizedChore *pChore); + + /// <summary> + /// Notifies virtual processors that work affinitized to them has become available in the schedule group segment. + /// </summary> + virtual void NotifyAffinitizedWork(); + + protected: + + + private: + friend class SchedulerBase; + friend class CacheLocalScheduleGroup; + friend class ContextBase; + friend class ExternalContextBase; + friend class InternalContextBase; + friend class ThreadInternalContext; + friend class SchedulingNode; + friend class SchedulingRing; + friend class VirtualProcessor; + + // + // Private data + // + + // Each schedule group has three stores of work. It has a collection of runnable contexts, + // a FIFO queue of realized chores and a list of workqueues that hold unrealized chores. + + // A collection of Runnable contexts. + SafeSQueue<InternalContextBase, _HyperNonReentrantLock> m_runnableContexts; + + // + // Private methods + // + + /// <summary> + /// Puts a runnable context into the runnables collection in the schedule group. + /// </summary> + void AddToRunnablesCollection(InternalContextBase *pContext); + + InternalContextBase *GetRunnableContext() + { + if (m_runnableContexts.Empty()) + return NULL; + + InternalContextBase *pContext = m_runnableContexts.Dequeue(); +#if defined(_DEBUG) + SetContextDebugBits(pContext, CTX_DEBUGBIT_REMOVEDFROMRUNNABLES); +#endif // _DEBUG + return pContext; + } + }; + + class CacheLocalScheduleGroup : public ScheduleGroupBase + { + public: + + /// <summary> + /// Constructs a new cache local schedule group. + /// </summary> + CacheLocalScheduleGroup(SchedulerBase *pScheduler, location* pGroupPlacement) : + ScheduleGroupBase(pScheduler, pGroupPlacement) + { + m_kind = CacheLocalScheduling; + } + + /// <summary> + /// Places a chore in a mailbox associated with the schedule group which is biased towards tasks being picked up from the specified + /// location. + /// </summary> + /// <param name="pChore"> + /// The chore to mail. + /// </param> + /// <param name="pPlacement"> + /// A pointer to a location where the chore will be mailed. + /// </param> + /// <returns> + /// The mailbox slot into which the chore was placed. + /// </returns> + /// <remarks> + /// A mailed chore should also be placed on its regular work stealing queue. The mailing must come first and once mailed, the chore body + /// cannot be referenced until the slot is successfully claimed via a call to the ClaimSlot method. + /// </remarks> + virtual Mailbox<_UnrealizedChore>::Slot MailChore(_UnrealizedChore * pChore, + location * pPlacement, + ScheduleGroupSegmentBase ** ppDestinationSegment); + protected: + + /// <summary> + /// Allocates a new cache local schedule group segment within the specified group and ring with the specified affinity. + /// </summary> + /// <param name="pSegmentAffinity"> + /// The affinity for the segment. + /// </param> + /// <param name="pOwningRing"> + /// The scheduling ring to which the newly allocated segment will belong. + /// </param> + /// <returns> + /// A new cache local schedule group within the specified group and ring with the specified affinity. + /// </returns> + virtual ScheduleGroupSegmentBase* AllocateSegment(SchedulingRing *pOwningRing, location* pSegmentAffinity) + { + return _concrt_new CacheLocalScheduleGroupSegment(this, pOwningRing, pSegmentAffinity); + } + }; +} // namespace details +} // namespace Concurrency diff --git a/test_data/lots_of_files/ConcurrencySal.h b/test_data/lots_of_files/ConcurrencySal.h new file mode 100644 index 0000000..a552040 --- /dev/null +++ b/test_data/lots_of_files/ConcurrencySal.h @@ -0,0 +1,357 @@ +/*** +*concurrencysal.h - markers for documenting the concurrent semantics of APIs +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains macros for Concurrency SAL annotations. Definitions +* starting with _Internal are low level macros that are subject to change. +* Users should not use those low level macros directly. +* [ANSI] +* +* [Public] +* +****/ + +#ifndef CONCURRENCYSAL_H +#define CONCURRENCYSAL_H + +#pragma once + +#ifdef __cplusplus // [ +extern "C" { +#endif // ] + +#if !defined(__midl) && defined(_PREFAST_) && _MSC_VER >= 1000 && !defined(_SDV_) + +__ANNOTATION(SAL_guarded_by(__deferTypecheck void *)); +__ANNOTATION(SAL_write_guarded_by(__deferTypecheck void *)); +__ANNOTATION(SAL_requires_lock_held(__deferTypecheck void *)); +__ANNOTATION(SAL_requires_exclusive_lock_held(__deferTypecheck void *)); +__ANNOTATION(SAL_requires_shared_lock_held(__deferTypecheck void *)); +__ANNOTATION(SAL_requires_lock_not_held(__deferTypecheck void *)); +__ANNOTATION(SAL_requires_no_locks_held(void)); +__ANNOTATION(SAL_set_lock_count_to_zero(__deferTypecheck void *)); +__ANNOTATION(SAL_set_lock_count_to_one(__deferTypecheck void *)); +__ANNOTATION(SAL_acquires_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_acquires_exclusive_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_acquires_shared_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_releases_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_releases_exclusive_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_releases_shared_lock(__deferTypecheck void *)); +__ANNOTATION(SAL_ignore_lock_match(__deferTypecheck void *)); +__ANNOTATION(SAL_has_lock_property(__AuToQuOtE __In_impl_ char *)); +__ANNOTATION(SAL_has_lock_level(__AuToQuOtE __In_impl_ char *)); +__ANNOTATION(SAL_lock_level_order(__deferTypecheck void *, __deferTypecheck void *)); +__ANNOTATION(SAL_no_competing_thread(void)); +__ANNOTATION(SAL_set_same_lock(__deferTypecheck void *, __deferTypecheck void *)); + +/* + * pre-defined global system locks + */ +extern int _Global_interlock_; +extern int _Global_cancel_spin_lock_; +extern int _Global_critical_region_; + +/* + * Annotation identifiers + */ +#define _Internal_create_CSAL_identifier_(id) const char id##[] = ""; + +_Internal_create_CSAL_identifier_(_Lock_kind_mutex_) +_Internal_create_CSAL_identifier_(_Lock_kind_event_) +_Internal_create_CSAL_identifier_(_Lock_kind_semaphore_) +_Internal_create_CSAL_identifier_(_Lock_kind_spin_lock_) +_Internal_create_CSAL_identifier_(_Lock_kind_critical_section_) + +/* + * data protection + */ +#define _Guarded_by_(lock) _SAL2_Source_(_Guarded_by_, (lock), _SA_annotes1(SAL_guarded_by,lock)) +#define _Write_guarded_by_(lock) _SAL2_Source_(_Write_guarded_by_, (lock), _SA_annotes1(SAL_write_guarded_by,lock)) +#define _Interlocked_ _Guarded_by_(_Global_interlock_) + +/* + * interlocked operand used in interlocked instructions + */ +#ifndef _Interlocked_operand_ +#define _Interlocked_operand_ _SAL2_Source_(_Interlocked_operand_, (), _Pre_ _SA_annotes0(SAL_interlocked)) +#endif + +/* + * caller/callee locking contracts + */ +#define _Requires_lock_held_(lock) _SAL2_Source_(_Requires_lock_held_, (lock), _Pre_ _SA_annotes1(SAL_requires_lock_held,lock)) +#define _Requires_exclusive_lock_held_(lock) _SAL2_Source_(_Requires_exclusive_lock_held_, (lock), _Pre_ _SA_annotes1(SAL_requires_exclusive_lock_held,lock)) +#define _Requires_shared_lock_held_(lock) _SAL2_Source_(_Requires_shared_lock_held_, (lock), _Pre_ _SA_annotes1(SAL_requires_shared_lock_held,lock)) + +#define _Requires_lock_not_held_(lock) _SAL2_Source_(_Requires_lock_not_held_, (lock), _Pre_ _SA_annotes1(SAL_requires_lock_not_held,lock)) +#define _Requires_no_locks_held_ _SAL2_Source_(_Requires_no_locks_held_, (), _Pre_ _SA_annotes0(SAL_requires_no_locks_held)) + +/* + * acquire/release locking side effects + */ +#define _Acquires_lock_(lock) _SAL2_Source_(_Acquires_lock_, (lock), _Post_ _SA_annotes1(SAL_acquires_lock,lock)) +#define _Acquires_exclusive_lock_(lock) _SAL2_Source_(_Acquires_exclusive_lock_, (lock), _Post_ _SA_annotes1(SAL_acquires_exclusive_lock,lock)) +#define _Acquires_shared_lock_(lock) _SAL2_Source_(_Acquires_shared_lock_, (lock), _Post_ _SA_annotes1(SAL_acquires_shared_lock,lock)) + +#define _Releases_lock_(lock) _SAL2_Source_(_Releases_lock_, (lock), _Post_ _SA_annotes1(SAL_releases_lock,lock)) +#define _Releases_exclusive_lock_(lock) _SAL2_Source_(_Releases_exclusive_lock_, (lock), _Post_ _SA_annotes1(SAL_releases_exclusive_lock,lock)) +#define _Releases_shared_lock_(lock) _SAL2_Source_(_Releases_shared_lock_, (lock), _Post_ _SA_annotes1(SAL_releases_shared_lock,lock)) + +/* + * acquire/release locking side effects for non-reentrant locks + */ +#define _Acquires_nonreentrant_lock_(lock) \ + _SAL2_Source_(_Acquires_nonreentrant_lock_, (lock), \ + _Requires_lock_not_held_(lock) \ + _Acquires_lock_(lock)) + +#define _Releases_nonreentrant_lock_(lock) \ + _SAL2_Source_(_Releases_nonreentrant_lock_, (lock), \ + _Requires_lock_held_(lock) \ + _Releases_lock_(lock)) + +#define _Post_same_lock_(a,b) _SAL2_Source_(_Post_same_lock_, (a,b), _Post_ _SA_annotes2(SAL_set_same_lock,a,b)) + +/* + * lock level + */ +#define _Create_lock_level_(level) _Internal_create_CSAL_identifier_(level) + +#define _Has_lock_level_(level) _SAL2_Source_(_Has_lock_level_, (level), _SA_annotes1(SAL_has_lock_level,#level)) + +#define _Internal_lock_level_order_(a,b) _SAL2_Source_(_Internal_lock_level_order_, (a,b), _SA_annotes2(SAL_lock_level_order,a,b)) +#define _Csalcat1_(x,y) x##y +#define _Csalcat2_(x,y) _Csalcat1_(x,y) + +#define _Lock_level_order_(a,b) \ + extern _Internal_lock_level_order_(a,b) void _Sal_order_##a##_##b(_In_z_ char*a, _In_z_ char*b); \ + static __inline void CSALCAT2(CSAL_LockOrder,__COUNTER__)(void){_Sal_order_##a##_##b(#a,#b);} + +/* + * threading context + */ +#define _No_competing_thread_ _SAL2_Source_(_No_competing_thread_, (), _Pre_ _SA_annotes0(SAL_no_competing_thread)) + +/* + * refinement and suppression + */ +extern _Acquires_lock_(*plock) void _Internal_acquires_lock_(void* plock); +extern _Releases_lock_(*plock) void _Internal_releases_lock_(void* plock); + +#define _Internal_set_lock_count_to_zero_(lock) _SAL2_Source_(Internal_set_lock_count_to_zero_, (lock), _Post_ _SA_annotes1(SAL_set_lock_count_to_zero,lock)) +#define _Internal_set_lock_count_to_one_(lock) _SAL2_Source_(_Internal_set_lock_count_to_one_, (lock), _Post_ _SA_annotes1(SAL_set_lock_count_to_one,lock)) + +extern _Internal_set_lock_count_to_one_(*plock) void _Internal_lock_held_(void* plock); +extern _Internal_set_lock_count_to_zero_(*plock) void _Internal_lock_not_held_(void* plock); +extern _Post_same_lock_(*plock1, *plock2) void _Internal_same_lock_(void* plock1, void* plock2); + +#define _Analysis_assume_lock_acquired_(lock) _Internal_acquires_lock_((void*)(&(lock))) +#define _Analysis_assume_lock_released_(lock) _Internal_releases_lock_((void*)(&(lock))) + +#define _Analysis_assume_lock_held_(lock) _Internal_lock_held_((void*)(&(lock))) +#define _Analysis_assume_lock_not_held_(lock) _Internal_lock_not_held_((void*)(&(lock))) +#define _Analysis_assume_same_lock_(lock1, lock2) _Internal_same_lock_((void*)(&(lock1)), (void*)(&(lock2))) + +/* + * _Function_ignore_lock_checking_ may be deprecated in future versions of SAL + */ +#define _Function_ignore_lock_checking_(lock) _SAL2_Source_(_Function_ignore_lock_checking_, (lock), _Pre_ _SA_annotes1(SAL_ignore_lock_match,lock)) +extern _Function_ignore_lock_checking_(*plock) void _Internal_suppress_lock_checking_(void* plock); + +/* + * _Analysis_suppress_lock_checking_ may be deprecated in future versions of SAL + */ +#define _Analysis_suppress_lock_checking_(lock) _Internal_suppress_lock_checking_((void*)(&(lock))); + +#define _Benign_race_begin_ __pragma(warning(push)) __pragma(warning(disable:26100 26101 26150 26130 26180 26131 26181 28112)) +#define _Benign_race_end_ __pragma(warning(pop)) + +#define _No_competing_thread_begin_ __pragma(warning(push)) __pragma(warning(disable:26100 26101 26150 26101 26151 26110 26160 26130 26180 26131 26181 28112)) +#define _No_competing_thread_end_ __pragma(warning(pop)) + +/* + * lock kinds + */ +#define _Has_lock_kind_(kind) _SAL2_Source_(_Has_lock_kind_, (kind), _SA_annotes1(SAL_has_lock_property,#kind)) + + +/* + * Old spelling + * Note: the old version may be deprecated in the future!!! + */ +extern int __system_interlock; +extern int __system_cancel_spinlock; +extern int __system_critical_region; + +#define __guarded_by(lock) _SAL1_1_Source_(__guarded_by, (lock), _SA_annotes1(SAL_guarded_by,lock)) +#define __write_guarded_by(lock) _SAL1_1_Source_(__write_guarded_by, (lock), _SA_annotes1(SAL_write_guarded_by,lock)) +#define __interlocked __guarded_by(_Global_interlock_) + +/* + * caller/callee locking contracts + */ +#define __requires_lock_held(lock) _SAL1_1_Source_(__requires_lock_held, (lock), __pre _SA_annotes1(SAL_requires_lock_held,lock)) +#define __requires_exclusive_lock_held(lock) _SAL1_1_Source_(__requires_exclusive_lock_held, (lock), __pre _SA_annotes1(SAL_requires_exclusive_lock_held,lock)) +#define __requires_shared_lock_held(lock) _SAL1_1_Source_(__requires_shared_lock_held, (lock), __pre _SA_annotes1(SAL_requires_shared_lock_held,lock)) + +#define __requires_lock_not_held(lock) _SAL1_1_Source_(__requires_lock_not_held, (lock), __pre _SA_annotes1(SAL_requires_lock_not_held,lock)) +#define __requires_no_locks_held _SAL1_1_Source_(__requires_no_locks_held, (), __pre _SA_annotes0(SAL_requires_no_locks_held)) + +/* + * acquire/release locking side effects + */ +#define __acquires_lock(lock) _SAL1_1_Source_(__acquires_lock, (lock), __post _SA_annotes1(SAL_acquires_lock,lock)) +#define __acquires_exclusive_lock(lock) _SAL1_1_Source_(__acquires_exclusive_lock, (lock), __post _SA_annotes1(SAL_acquires_exclusive_lock,lock)) +#define __acquires_shared_lock(lock) _SAL1_1_Source_(__acquires_shared_lock, (lock), __post _SA_annotes1(SAL_acquires_shared_lock,lock)) + +#define __releases_lock(lock) _SAL1_1_Source_(__releases_lock, (lock), __post _SA_annotes1(SAL_releases_lock,lock)) +#define __releases_exclusive_lock(lock) _SAL1_1_Source_(__releases_exclusive_lock, (lock),__post _SA_annotes1(SAL_releases_exclusive_lock,lock)) +#define __releases_shared_lock(lock) _SAL1_1_Source_(__releases_shared_lock, (lock), __post _SA_annotes1(SAL_releases_shared_lock,lock)) + +/* + * lock properties + * The following kind options are supported: + * __has_lock_property(MUTEX) + * __has_lock_property(EVENT) + * __has_lock_property(SEMAPHORE) + * __has_lock_property(OTHER_HANDLE) + * __has_lock_property(REENTRANT) + * __has_lock_property(NON_REENTRANT) + */ +#define __has_lock_property(kind) _SAL1_1_Source_(__has_lock_property, (kind), _SA_annotes1(SAL_has_lock_property,#kind)) + +/* + * lock level + */ +#define __declare_lock_level(level) _Internal_create_CSAL_identifier_(level) +#define __has_lock_level(level) _SAL1_1_Source_(__has_lock_level, (level), _SA_annotes1(SAL_has_lock_level,#level)) + +#define __internal_lock_level_order(a,b) _SAL1_1_Source_(__internal_lock_level_order, (a,b), _SA_annotes2(SAL_lock_level_order,#a,#b)) +#define CSALCAT1(x,y) x##y +#define CSALCAT2(x,y) CSALCAT1(x,y) + +#define __lock_level_order(a,b) \ + extern __internal_lock_level_order(a,b) void __sal_order_##a##_##b(__in_z char*a, __in_z char*b); \ + static __inline void CSALCAT2(CSAL_LockOrder,__COUNTER__)(void){__sal_order_##a##_##b(#a,#b);} + +/* + * threading context + */ +#define __no_competing_thread _SAL1_1_Source_(__no_competing_thread, (), __pre _SA_annotes0(SAL_no_competing_thread)) + +/* + * refinement and suppression + */ +extern __acquires_lock(*plock) void __internal_acquires_lock(void* plock); +extern __releases_lock(*plock) void __internal_releases_lock(void* plock); + +#define __analysis_assume_lock_acquired(lock) __internal_acquires_lock((void*)(&(lock))) +#define __analysis_assume_lock_released(lock) __internal_releases_lock((void*)(&(lock))) + +#define __function_ignore_lock_checking(lock) _SAL1_1_Source_(__function_ignore_lock_cleanup, (lock), __pre _SA_annotes1(SAL_ignore_lock_match,lock)) +extern __function_ignore_lock_checking(*plock) void __internal_suppress_lock_checking(void* plock); + +#define __analysis_suppress_lock_checking(lock) __internal_suppress_lock_checking((void*)(&(lock))); + +#define BENIGN_RACE_BEGIN __pragma(warning(push)) __pragma(warning(disable:26100 26150 26130 26180 26131 26181)) +#define BENIGN_RACE_END __pragma(warning(pop)) + +#define NO_COMPETING_THREAD_BEGIN __pragma(warning(push)) __pragma(warning(disable:26100 26150 26101 26151 26110 26160 26130 26180 26131 26181)) +#define NO_COMPETING_THREAD_END __pragma(warning(pop)) + +#else + +#ifndef _Interlocked_operand_ +#define _Interlocked_operand_ +#endif + +#define _Guarded_by_(lock) +#define _Write_guarded_by_(lock) +#define _Interlocked_ +#define _Requires_lock_held_(lock) +#define _Requires_exclusive_lock_held_(lock) +#define _Requires_shared_lock_held_(lock) +#define _Requires_lock_not_held_(lock) +#define _Requires_no_locks_held_ +#define _Acquires_lock_(lock) +#define _Acquires_exclusive_lock_(lock) +#define _Acquires_shared_lock_(lock) +#define _Releases_lock_(lock) +#define _Releases_exclusive_lock_(lock) +#define _Releases_shared_lock_(lock) +#define _Acquires_nonreentrant_lock_(lock) +#define _Releases_nonreentrant_lock_(lock) + +#define _Post_same_lock_(lock1,lock2) + +#define _Internal_set_lock_count_(lock, count) + +#define _Create_lock_level_(level) +#define _Has_lock_level_(level) +#define _Internal_lock_level_order_(a,b) +#define _Csalcat1_(x,y) +#define _Csalcat2_(x,y) +#define _Lock_level_order_(a,b) +#define _No_competing_thread_ +#define _Analysis_assume_lock_acquired_(lock) +#define _Analysis_assume_lock_released_(lock) +#define _Analysis_assume_lock_held_(lock) +#define _Analysis_assume_lock_not_held_(lock) +#define _Analysis_assume_same_lock_(lock1, lock2) +#define _Function_ignore_lock_checking_(lock) +#define _Analysis_suppress_lock_checking_(lock) + +#define _Benign_race_begin_ __pragma(warning(push)) +#define _Benign_race_end_ __pragma(warning(pop)) + +#define _No_competing_thread_begin_ __pragma(warning(push)) +#define _No_competing_thread_end_ __pragma(warning(pop)) + +#define _Has_lock_kind_(kind) + +/* + * Old spelling: will be deprecated + */ +#define __guarded_by(lock) +#define __write_guarded_by(lock) +#define __interlocked +#define __requires_lock_held(lock) +#define __requires_exclusive_lock_held(lock) +#define __requires_shared_lock_held(lock) +#define __requires_lock_not_held(lock) +#define __requires_no_locks_held +#define __acquires_lock(lock) +#define __acquires_exclusive_lock(lock) +#define __acquires_shared_lock(lock) +#define __releases_lock(lock) +#define __releases_exclusive_lock(lock) +#define __releases_shared_lock(lock) + +#define __has_lock_property(kind) +#define __declare_lock_level(level) +#define __has_lock_level(level) +#define __internal_lock_level_order(a,b) +#define CSALCAT1(x,y) +#define CSALCAT2(x,y) +#define __lock_level_order(a,b) +#define __no_competing_thread +#define __analysis_assume_lock_acquired(lock) +#define __analysis_assume_lock_released(lock) +#define __function_ignore_lock_checking(lock) +#define __analysis_suppress_lock_checking(lock) + +#define BENIGN_RACE_BEGIN __pragma(warning(push)) +#define BENIGN_RACE_END __pragma(warning(pop)) + +#define NO_COMPETING_THREAD_BEGIN __pragma(warning(push)) +#define NO_COMPETING_THREAD_END __pragma(warning(pop)) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // CONCURRENCYSAL_H diff --git a/test_data/lots_of_files/MD5.cpp b/test_data/lots_of_files/MD5.cpp new file mode 100644 index 0000000..290a055 --- /dev/null +++ b/test_data/lots_of_files/MD5.cpp @@ -0,0 +1,366 @@ +/* MD5 + converted to C++ class by Frank Thilo (thilo@unix-ag.org) + for bzflag (http://www.bzflag.org) + + based on: + + md5.h and md5.c + reference implementation of RFC 1321 + +Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + +*/ + +/* interface header */ +#include "MD5.h" + +#include <cstdlib> +#include <cstdio> +#include <cmath> +#include <sstream> + +// Constants for MD5Transform routine. +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +/////////////////////////////////////////////// + +// F, G, H and I are basic MD5 functions. +inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) { + return (x&y) | (~x&z); +} + +inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) { + return (x&z) | (y&~z); +} + +inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) { + return x^y^z; +} + +inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) { + return y ^ (x | ~z); +} + +// rotate_left rotates x left n bits. +inline MD5::uint4 MD5::rotate_left(uint4 x, int n) { + return (x << n) | (x >> (32-n)); +} + +// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. +// Rotation is separate from addition to prevent recomputation. +inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { + a = rotate_left(a+ F(b,c,d) + x + ac, s) + b; +} + +inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { + a = rotate_left(a + G(b,c,d) + x + ac, s) + b; +} + +inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { + a = rotate_left(a + H(b,c,d) + x + ac, s) + b; +} + +inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { + a = rotate_left(a + I(b,c,d) + x + ac, s) + b; +} + +////////////////////////////////////////////// + +// default ctor, just initailize +MD5::MD5() +{ + init(); +} + +////////////////////////////////////////////// + +// nifty shortcut ctor, compute MD5 for string and finalize it right away +MD5::MD5(const std::string &text) +{ + init(); + update(text.c_str(), (MD5::size_type)text.length()); + finalize(); +} + +////////////////////////////// + +void MD5::init() +{ + finalized=false; + + for (int i = 0; i < blocksize; ++i) buffer[i] = 0; + for (int i = 0; i < 16; ++i) digest[i] = 0; + + count[0] = 0; + count[1] = 0; + + // load magic initialization constants. + state[0] = 0x67452301; + state[1] = 0xefcdab89; + state[2] = 0x98badcfe; + state[3] = 0x10325476; +} + +////////////////////////////// + +// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4. +void MD5::decode(uint4 output[], const uint1 input[], size_type len) +{ + for (unsigned int i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) | + (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24); +} + +////////////////////////////// + +// encodes input (uint4) into output (unsigned char). Assumes len is +// a multiple of 4. +void MD5::encode(uint1 output[], const uint4 input[], size_type len) +{ + for (size_type i = 0, j = 0; j < len; i++, j += 4) { + output[j] = input[i] & 0xff; + output[j+1] = (input[i] >> 8) & 0xff; + output[j+2] = (input[i] >> 16) & 0xff; + output[j+3] = (input[i] >> 24) & 0xff; + } +} + +////////////////////////////// + +// apply MD5 algo on a block +void MD5::transform(const uint1 block[blocksize]) +{ + uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + decode (x, block, blocksize); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + // Zeroize sensitive information. + memset(x, 0, sizeof x); +} + +////////////////////////////// + +// MD5 block update operation. Continues an MD5 message-digest +// operation, processing another message block +void MD5::update(const unsigned char input[], size_type length) +{ + // compute number of bytes mod 64 + size_type index = count[0] / 8 % blocksize; + + // Update number of bits + if ((count[0] += (length << 3)) < (length << 3)) + count[1]++; + count[1] += (length >> 29); + + // number of bytes we need to fill in buffer + size_type firstpart = 64 - index; + + size_type i; + + // transform as many times as possible. + if (length >= firstpart) + { + // fill buffer first, transform + memcpy(&buffer[index], input, firstpart); + transform(buffer); + + // transform chunks of blocksize (64 bytes) + for (i = firstpart; i + blocksize <= length; i += blocksize) + transform(&input[i]); + + index = 0; + } + else + i = 0; + + // buffer remaining input + memcpy(&buffer[index], &input[i], length-i); +} + +////////////////////////////// + +// for convenience provide a verson with signed char +void MD5::update(const char input[], size_type length) +{ + update((const unsigned char*)input, length); +} + +////////////////////////////// + +// MD5 finalization. Ends an MD5 message-digest operation, writing the +// the message digest and zeroizing the context. +MD5& MD5::finalize() +{ + if (!finalized) { + static unsigned char padding[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + // Save number of bits + unsigned char bits[8]; + encode(bits, count, 8); + + // pad out to 56 mod 64. + size_type index = count[0] / 8 % 64; + size_type padLen = (index < 56) ? (56 - index) : (120 - index); + update(padding, padLen); + + // Append length (before padding) + update(bits, 8); + + // Store state in digest + encode(digest, state, 16); + + // Zeroize sensitive information. + memset(buffer, 0, sizeof buffer); + memset(count, 0, sizeof count); + + finalized=true; + } + + return *this; +} + +////////////////////////////// + +// return hex representation of digest as string +std::string MD5::hexdigest() const +{ + if (!finalized) + return ""; + + char buf[33]; + for (int i=0; i<16; i++) + sprintf(buf+i*2, "%02x", digest[i]); + buf[32]=0; + + return std::string(buf); +} + +////////////////////////////// + +std::ostream& operator<<(std::ostream& out, MD5 md5) +{ + return out << md5.hexdigest(); +} + +////////////////////////////// + +std::string md5(const std::string &str) +{ + MD5 md5 = MD5(str); + + return md5.hexdigest(); +} \ No newline at end of file diff --git a/test_data/lots_of_files/MD5.h b/test_data/lots_of_files/MD5.h new file mode 100644 index 0000000..f435290 --- /dev/null +++ b/test_data/lots_of_files/MD5.h @@ -0,0 +1,98 @@ +/* MD5 + converted to C++ class by Frank Thilo (thilo@unix-ag.org) + for bzflag (http://www.bzflag.org) + + based on: + + md5.h and md5.c + reference implementation of RFC 1321 + +Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + +*/ + +#pragma once +#ifndef _MD5_H_ +#define _MD5_H_ + + +#define _HAS_EXCEPTIONS (0) +#define _CRT_SECURE_NO_WARNINGS + +#include <cstring> +#include <string> + + +// a small class for calculating MD5 hashes of strings or byte arrays +// it is not meant to be fast or secure +// +// usage: 1) feed it blocks of uchars with update() +// 2) finalize() +// 3) get hexdigest() string +// or +// MD5(std::string).hexdigest() +// +// assumes that char is 8 bit and int is 32 bit +class MD5 +{ +public: + typedef unsigned int size_type; // must be 32bit + + MD5(); + MD5(const std::string& text); + void update(const unsigned char *buf, size_type length); + void update(const char *buf, size_type length); + MD5& finalize(); + std::string hexdigest() const; + friend std::ostream& operator<<(std::ostream&, MD5 md5); + +private: + void init(); + typedef unsigned char uint1; // 8bit + typedef unsigned int uint4; // 32bit + enum {blocksize = 64}; // VC6 won't eat a const static int here + + void transform(const uint1 block[blocksize]); + static void decode(uint4 output[], const uint1 input[], size_type len); + static void encode(uint1 output[], const uint4 input[], size_type len); + + bool finalized; + uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk + uint4 count[2]; // 64bit counter for number of bits (lo, hi) + uint4 state[4]; // digest so far + uint1 digest[16]; // the result + + // low level logic operations + static inline uint4 F(uint4 x, uint4 y, uint4 z); + static inline uint4 G(uint4 x, uint4 y, uint4 z); + static inline uint4 H(uint4 x, uint4 y, uint4 z); + static inline uint4 I(uint4 x, uint4 y, uint4 z); + static inline uint4 rotate_left(uint4 x, int n); + static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); + static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); + static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); + static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); +}; + +std::string md5(const std::string &str); + +#endif diff --git a/test_data/lots_of_files/_ctype.c b/test_data/lots_of_files/_ctype.c new file mode 100644 index 0000000..9ba5e5c --- /dev/null +++ b/test_data/lots_of_files/_ctype.c @@ -0,0 +1,384 @@ +/*** +*_ctype.c - function versions of ctype macros +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* This files provides function versions of the character +* classification and conversion macros in ctype.h. +* +*******************************************************************************/ + +/*** +*ctype - Function versions of ctype macros +* +*Purpose: +* Function versions of the macros in ctype.h. In order to define +* these, we use a trick -- we use parentheses so we can use the +* name in the function declaration without macro expansion, then +* we use the macro in the definition part. +* +* Functions defined: +* isalpha isupper islower +* isdigit isxdigit isspace +* ispunct isalnum isprint +* isgraph isctrl __isascii +* __toascii __iscsym __iscsymf +* isblank +* +*Entry: +* int c = character to be tested +*Exit: +* returns non-zero = character is of the requested type +* 0 = character is NOT of the requested type +* +*Exceptions: +* None. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <ctype.h> +#include <locale.h> +#include <mtdll.h> +#include <setlocal.h> + +#ifdef _DEBUG +#define __fast_ch_check(a,b) _chvalidator(a,b) +#else /* _DEBUG */ +#define __fast_ch_check(a,b) (__initiallocinfo.pctype[(a)] & (b)) +#endif /* _DEBUG */ + +extern "C" +{ +extern __inline int (__cdecl _isalpha_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isalpha_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isalpha) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _ALPHA); + } + else + { + return (_isalpha_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isupper_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isupper_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isupper) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _UPPER); + } + else + { + return (_isupper_l)(c, NULL); + } +} + +extern __inline int (__cdecl _islower_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _islower_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl islower) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _LOWER); + } + else + { + return (_islower_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isdigit_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isdigit_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isdigit) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _DIGIT); + } + else + { + return (_isdigit_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isxdigit_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isxdigit_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isxdigit) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _HEX); + } + else + { + return (_isxdigit_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isspace_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isspace_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isspace) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _SPACE); + } + else + { + return (_isspace_l)(c, NULL); + } +} + +extern __inline int (__cdecl _ispunct_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _ispunct_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl ispunct) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _PUNCT); + } + else + { + return (_ispunct_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isblank_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isblank_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isblank) ( + int c + ) +{ + if (__locale_changed == 0) + { + return (c == '\t') ? _BLANK : __fast_ch_check(c, _BLANK); + } + else + { + return (_isblank_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isalnum_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isalnum_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isalnum) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _ALPHA|_DIGIT); + } + else + { + return (_isalnum_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isprint_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isprint_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isprint) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _BLANK|_PUNCT|_ALPHA|_DIGIT); + } + else + { + return (_isprint_l)(c, NULL); + } +} + +extern __inline int (__cdecl _isgraph_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _isgraph_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl isgraph) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _PUNCT|_ALPHA|_DIGIT); + } + else + { + return (_isgraph_l)(c, NULL); + } +} + +extern __inline int (__cdecl _iscntrl_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return _iscntrl_l(c, _loc_update.GetLocaleT()); +} + +extern __inline int (__cdecl iscntrl) ( + int c + ) +{ + if (__locale_changed == 0) + { + return __fast_ch_check(c, _CONTROL); + } + else + { + return (_iscntrl_l)(c, NULL); + } +} + +extern __inline int (__cdecl __isascii) ( + int c + ) +{ + return __isascii(c); +} + +extern __inline int (__cdecl __toascii) ( + int c + ) +{ + return __toascii(c); +} + +extern __inline int (__cdecl _iscsymf_l) ( + int c, + _locale_t plocinfo + ) +{ + return (_isalpha_l)(c, plocinfo) || (c) == '_'; +} +extern __inline int (__cdecl __iscsymf) ( + int c + ) +{ + return __iscsymf(c); +} + +extern __inline int (__cdecl _iscsym_l) ( + int c, + _locale_t plocinfo + ) +{ + return (_isalnum_l)(c, plocinfo) || (c) == '_'; +} + +extern __inline int (__cdecl __iscsym) ( + int c + ) +{ + return __iscsym((unsigned char)(c)); +} +} diff --git a/test_data/lots_of_files/_filbuf.c b/test_data/lots_of_files/_filbuf.c new file mode 100644 index 0000000..17c5d31 --- /dev/null +++ b/test_data/lots_of_files/_filbuf.c @@ -0,0 +1,211 @@ +/*** +*_filbuf.c - fill buffer and get character +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _filbuf() - fill buffer and read first character, allocate +* buffer if there is none. Used from getc(). +* defines _filwbuf() - fill buffer and read first wide character, allocate +* buffer if there is none. Used from getwc(). +* +*Note: +* this file is included in safecrt.lib build directly, plese refer +* to safecrt_filwbuf.c +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <file2.h> +#include <io.h> +#include <dbgint.h> +#include <malloc.h> +#include <internal.h> +#include <msdos.h> +#include <wchar.h> +#include <mtdll.h> +#include <tchar.h> + +#ifndef _UNICODE + +/*** +*int _filbuf(stream) - fill buffer and get first character +* +*Purpose: +* get a buffer if the file doesn't have one, read into it, return first +* char. try to get a buffer, if a user buffer is not assigned. called +* only from getc; intended for use only within library. assume no input +* stream is to remain unbuffered when memory is available unless it is +* marked _IONBF. at worst, give it a single char buffer. the need for a +* buffer, no matter how small, becomes evident when we consider the +* ungetc's necessary in scanf +* +* [NOTE: Multi-thread - _filbuf() assumes that the caller has aquired +* the stream lock, if needed.] +* +*Entry: +* FILE *stream - stream to read from +* +*Exit: +* returns first character from buffer (next character to be read) +* returns EOF if the FILE is actually a string, or not open for reading, +* or if open for writing or if no more chars to read. +* all fields in FILE structure may be changed except _file. +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _filbuf ( + FILE *str + ) + +#else /* _UNICODE */ + +/*** +*int _filwbuf(stream) - fill buffer and get first wide character +* +*Purpose: +* get a buffer if the file doesn't have one, read into it, return first +* char. try to get a buffer, if a user buffer is not assigned. called +* only from getc; intended for use only within library. assume no input +* stream is to remain unbuffered when memory is available unless it is +* marked _IONBF. at worst, give it a single char buffer. the need for a +* buffer, no matter how small, becomes evident when we consider the +* ungetc's necessary in scanf +* +* [NOTE: Multi-thread - _filwbuf() assumes that the caller has aquired +* the stream lock, if needed.] +* +*Entry: +* FILE *stream - stream to read from +* +*Exit: +* returns first wide character from buffer (next character to be read) +* returns WEOF if the FILE is actually a string, or not open for reading, +* or if open for writing or if no more chars to read. +* all fields in FILE structure may be changed except _file. +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _filwbuf ( + FILE *str + ) + +#endif /* _UNICODE */ + +{ + FILE *stream=NULL; + +#ifdef _UNICODE + int is_split_character = 0; + unsigned char leftover_low_order_byte = 0; +#endif /* _UNICODE */ + + /* In safecrt, we assume we always have a buffer */ + _VALIDATE_RETURN(str != NULL, EINVAL, _TEOF); + + /* Init pointer to _iob2 entry. */ + stream = str; + + if (!inuse(stream) || stream->_flag & _IOSTRG) + return(_TEOF); + + if (stream->_flag & _IOWRT) + { + stream->_flag |= _IOERR; + return(_TEOF); + } + + stream->_flag |= _IOREAD; + + /* Get a buffer, if necessary. */ + + if (!anybuf(stream)) + { +#ifndef _SAFECRT_IMPL + _getbuf(stream); +#else /* _SAFECRT_IMPL */ + /* In safecrt, we assume we always have a buffer */ + _VALIDATE_RETURN(FALSE, EINVAL, _TEOF); +#endif /* _SAFECRT_IMPL */ + } + else + { +#ifdef _UNICODE + /* When reading wchar_t elements, we must handle the case where a + two-byte character straddles the buffer boundary, with the low + order byte at the end of the old buffer and the high order byte + at the start of the new buffer. + + We do this here: if there is exactly one character left in the + buffer, we store that and set the is_split_character flag. After + we load the new buffer, we'll or this low order byte into the + result. */ + if (stream->_cnt == 1) + { + is_split_character = 1; + leftover_low_order_byte = (unsigned char)*stream->_ptr; + } +#endif /* _UNICODE */ + + stream->_ptr = stream->_base; + } + + stream->_cnt = _read(_fileno(stream), stream->_base, stream->_bufsiz); + +#ifndef _UNICODE + if ((stream->_cnt == 0) || (stream->_cnt == -1)) { +#else /* _UNICODE */ + if ((stream->_cnt == 0) || (stream->_cnt == 1) || stream->_cnt == -1) { +#endif /* _UNICODE */ + stream->_flag |= stream->_cnt ? _IOERR : _IOEOF; + stream->_cnt = 0; + return(_TEOF); + } + + if ( !(stream->_flag & (_IOWRT|_IORW)) && + ((_osfile_safe(_fileno(stream)) & (FTEXT|FEOFLAG)) == + (FTEXT|FEOFLAG)) ) + { + stream->_flag |= _IOCTRLZ; + } + + /* Check for small _bufsiz (_SMALL_BUFSIZ). If it is small and + if it is our buffer, then this must be the first _filbuf after + an fseek on a read-access-only stream. Restore _bufsiz to its + larger value (_INTERNAL_BUFSIZ) so that the next _filbuf call, + if one is made, will fill the whole buffer. */ + if ( (stream->_bufsiz == _SMALL_BUFSIZ) && (stream->_flag & + _IOMYBUF) && !(stream->_flag & _IOSETVBUF) ) + { + stream->_bufsiz = _INTERNAL_BUFSIZ; + } + +#ifndef _UNICODE + stream->_cnt--; + return(0xff & *stream->_ptr++); +#else /* _UNICODE */ + if (is_split_character) + { + /* If the character was split across buffers, we read only one byte + from the new buffer and or it with the leftover byte from the old + buffer. */ + unsigned char high_order_byte = (unsigned char)(*stream->_ptr); + wchar_t result = (high_order_byte << 8) | leftover_low_order_byte; + + --stream->_cnt; + ++stream->_ptr; + return (result); + } + else + { + stream->_cnt -= sizeof(wchar_t); + return (0xffff & *((wchar_t *)(stream->_ptr))++); + } +#endif /* _UNICODE */ + +} diff --git a/test_data/lots_of_files/_file.c b/test_data/lots_of_files/_file.c new file mode 100644 index 0000000..ca36911 --- /dev/null +++ b/test_data/lots_of_files/_file.c @@ -0,0 +1,352 @@ +/*** +*_file.c - Definition of _iob[], initializer and terminator. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines _iob[], the array of stdio control structures, the initializer +* and terminator routines, and the multithread locking for stdio. +* +*******************************************************************************/ + +#include <sect_attribs.h> +#include <cruntime.h> +#include <windows.h> +#include <stdio.h> +#include <file2.h> +#include <internal.h> +#include <malloc.h> +#include <rterr.h> +#include <dbgint.h> +#include <mtdll.h> + +/* + * Buffer for stdin. + */ + +char _bufin[_INTERNAL_BUFSIZ]; + +/* + * FILE descriptors; preset for stdin/out/err (note that the __tmpnum field + * is not initialized) + */ +FILE _iob[_IOB_ENTRIES] = { + /* _ptr, _cnt, _base, _flag, _file, _charbuf, _bufsiz */ + + /* stdin (_iob[0]) */ + + { _bufin, 0, _bufin, _IOREAD | _IOYOURBUF, 0, 0, _INTERNAL_BUFSIZ }, + + /* stdout (_iob[1]) */ + + { NULL, 0, NULL, _IOWRT, 1, 0, 0 }, + + /* stderr (_iob[3]) */ + + { NULL, 0, NULL, _IOWRT, 2, 0, 0 }, + +}; + + +/* These functions are for enabling STATIC_CPPLIB functionality */ +_CRTIMP FILE * __cdecl __iob_func(void) +{ + return _iob; +} + + +/* + * Pointer to array of FILE * or _FILEX * structures. + */ +void ** __piob; + +/* + * Number of open streams (set to _NSTREAM by default) + */ +#ifdef CRTDLL +int _nstream = _NSTREAM_; +#else /* CRTDLL */ +int _nstream; +#endif /* CRTDLL */ + + +/* + * Initializer and terminator for stdio + */ +int __cdecl __initstdio(void); +void __cdecl __endstdio(void); + +_CRTALLOC(".CRT$XIC") static _PIFV pinit = __initstdio; + +_CRTALLOC(".CRT$XPXA") static _PVFV pterm = __endstdio; + +#ifndef CRTDLL +/* + * _cflush is a dummy variable used to pull in _endstdio() when any STDIO + * routine is included in the user program. + */ +int _cflush = 0; +#endif /* CRTDLL */ + + +/*** +* __initstdio - Initialize the stdio system +* +*Purpose: +* Create and initialize the __piob array. +* +*Entry: <void> +* +*Exit: Returns _RT_STDIOINIT if error encountered. +* +*Uses: +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl __initstdio(void) +{ + int i; + +#ifndef CRTDLL + /* + * If the user has not supplied a definition of _nstream, set it + * to _NSTREAM_. If the user has supplied a value that is too small + * set _nstream to the minimum acceptable value (_IOB_ENTRIES). + */ + if ( _nstream == 0 ) + _nstream = _NSTREAM_; + else if ( _nstream < _IOB_ENTRIES ) + _nstream = _IOB_ENTRIES; +#endif /* CRTDLL */ + + /* + * Allocate the __piob array. Try for _nstream entries first. If this + * fails then reset _nstream to _IOB_ENTRIES and try again. If it + * still fails, bail out with an RTE. + */ + if ( (__piob = (void **)_calloc_crt( _nstream, sizeof(void *) )) == + NULL ) { + _nstream = _IOB_ENTRIES; + if ( (__piob = (void **)_calloc_crt( _nstream, sizeof(void *) )) + == NULL ) + return _RT_STDIOINIT; + } + + /* + * Initialize the first _IOB_ENTRIES to point to the corresponding + * entries in _iob[]. + */ + for ( i = 0 ; i < _IOB_ENTRIES ; i++ ) + __piob[i] = (void *)&_iob[i]; + + return 0; +} + + +/*** +* __endstdio - Terminate the stdio system +* +*Purpose: +* Terminate the stdio system +* +* (1) Flush all streams. (Do this even if we're going to +* call fcloseall since that routine won't do anything to the +* std streams.) +* +* (2) If returning to caller, close all streams. This is +* not necessary if the exe is terminating because the OS will +* close the files for us (much more efficiently, too). +* +*Entry: <void> +* +*Exit: <void> +* +*Uses: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl __endstdio(void) +{ + /* flush all streams */ + _flushall(); + + /* if in callable exit, close all streams */ + if (_exitflag) + _fcloseall(); + _free_crt(__piob); + __piob = NULL; +} + + +/*** +* _lock_file - Lock a FILE +* +*Purpose: +* Assert the lock for a stdio-level file +* +*Entry: +* pf = __piob[] entry (pointer to a FILE or _FILEX) +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _lock_file ( + FILE *pf + ) +{ + /* + * The way the FILE (pointed to by pf) is locked depends on whether + * it is part of _iob[] or not + */ + if ( (pf >= _iob) && (pf <= (&_iob[_IOB_ENTRIES-1])) ) + { + /* + * FILE lies in _iob[] so the lock lies in _locktable[]. + */ + _lock( _STREAM_LOCKS + (int)(pf - _iob) ); + /* We set _IOLOCKED to indicate we locked the stream */ + pf->_flag |= _IOLOCKED; + } + else + /* + * Not part of _iob[]. Therefore, *pf is a _FILEX and the + * lock field of the struct is an initialized critical + * section. + */ + EnterCriticalSection( &(((_FILEX *)pf)->lock) ); +} + + +/*** +* _lock_file2(i, s) - Lock the FILE +* +*Purpose: +* Assert the lock for a stdio-level file given by s == __piob[i]. +* +*Entry: +* s == __piob[i] +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _lock_file2 ( + int i, + void *s + ) +{ + /* + * The way the FILE is locked depends on whether it is part of _iob[] + * _iob[] or not + */ + if ( i < _IOB_ENTRIES ) + { + /* + * FILE lies in _iob[] so the lock lies in _locktable[]. + */ + _lock( _STREAM_LOCKS + i ); + /* We set _IOLOCKED to indicate we locked the stream */ + ((FILE*)s)->_flag |= _IOLOCKED; + } + else + /* + * Not part of _iob[]. Therefore, *s is a _FILEX and the + * lock field of the struct is an initialized critical + * section. + */ + EnterCriticalSection( &(((_FILEX *)s)->lock) ); +} + + +/*** +* _unlock_file - Unlock a FILE +* +*Purpose: +* Release the lock for a stdio-level file +* +*Entry: +* pf = __piob[] entry (pointer to a FILE or _FILEX) +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _unlock_file ( + FILE *pf + ) +{ + /* + * The way the FILE (pointed to by pf) is unlocked depends on whether + * it is part of _iob[] or not + */ + if ( (pf >= _iob) && (pf <= (&_iob[_IOB_ENTRIES-1])) ) + { + /* + * FILE lies in _iob[] so the lock lies in _locktable[]. + * We reset _IOLOCKED to indicate we unlock the stream. + */ + pf->_flag &= ~_IOLOCKED; + _unlock( _STREAM_LOCKS + (int)(pf - _iob) ); + } + else + /* + * Not part of _iob[]. Therefore, *pf is a _FILEX and the + * lock field of the struct is an initialized critical + * section. + */ + LeaveCriticalSection( &(((_FILEX *)pf)->lock) ); +} + + +/*** +* _unlock_file2(i, s) - Lock the FILE +* +*Purpose: +* Release the lock for a stdio-level file given by s == __piob[i]. +* +*Entry: +* s == __piob[i] +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _unlock_file2 ( + int i, + void *s + ) +{ + /* + * The way the FILE is locked depends on whether it is part of _iob[] + * _iob[] or not + */ + if ( i < _IOB_ENTRIES ) + { + /* + * FILE lies in _iob[] so the lock lies in _locktable[]. + * We reset _IOLOCKED to indicate we unlock the stream. + */ + ((FILE*)s)->_flag &= ~_IOLOCKED; + _unlock( _STREAM_LOCKS + i ); + } + else + /* + * Not part of _iob[]. Therefore, *s is a _FILEX and the + * lock field of the struct is an initialized critical + * section. + */ + LeaveCriticalSection( &(((_FILEX *)s)->lock) ); +} diff --git a/test_data/lots_of_files/_filwbuf.c b/test_data/lots_of_files/_filwbuf.c new file mode 100644 index 0000000..bbf94f5 --- /dev/null +++ b/test_data/lots_of_files/_filwbuf.c @@ -0,0 +1,23 @@ +/*** +*_filwbuf.c - fill buffer and get wide character +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _filwbuf() - fill buffer and read first character, allocate +* buffer if there is none. Used from getwc(). +* +*******************************************************************************/ + + + +#ifndef _UNICODE +#define _UNICODE 1 +#endif /* _UNICODE */ + +#ifndef UNICODE +#define UNICODE 1 +#endif /* UNICODE */ + +#include "_filbuf.c" + diff --git a/test_data/lots_of_files/_flsbuf.c b/test_data/lots_of_files/_flsbuf.c new file mode 100644 index 0000000..748a9c4 --- /dev/null +++ b/test_data/lots_of_files/_flsbuf.c @@ -0,0 +1,211 @@ +/*** +*_flsbuf.c - flush buffer and output character. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _flsbuf() - flush a file buffer and output a character. +* defines _flswbuf() - flush a file buffer and output a wide character. +* If no buffer, make one. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <file2.h> +#include <io.h> +#include <dbgint.h> +#include <malloc.h> +#include <msdos.h> +#include <wchar.h> +#include <internal.h> +#include <mtdll.h> +#include <tchar.h> + +#ifndef _UNICODE + +/*** +*int _flsbuf(ch, stream) - flush buffer and output character. +* +*Purpose: +* flush a buffer if this stream has one. if not, try to get one. put the +* next output char (ch) into the buffer (or output it immediately if this +* stream can't have a buffer). called only from putc. intended for use +* only within library. +* +* [NOTE: Multi-thread - It is assumed that the caller has aquired +* the stream lock.] +* +*Entry: +* FILE *stream - stream to flish and write on +* int ch - character to output. +* +*Exit: +* returns -1 if FILE is actually a string, or if can't write ch to +* unbuffered file, or if we flush a buffer but the number of chars +* written doesn't agree with buffer size. Otherwise returns ch. +* all fields in FILE struct can be affected except _file. +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _flsbuf ( + int ch, + FILE *str + ) + +#else /* _UNICODE */ + +/*** +*int _flswbuf(ch, stream) - flush buffer and output wide character. +* +*Purpose: +* flush a buffer if this stream has one. if not, try to get one. put the +* next output wide char (ch) into the buffer (or output it immediately if this +* stream can't have a buffer). called only from putwc. intended for use +* only within library. +* +* [NOTE: Multi-thread - It is assumed that the caller has aquired +* the stream lock.] +* +*Entry: +* FILE *stream - stream to flish and write on +* int ch - wide character to output. +* +*Exit: +* returns -1 if FILE is actually a string, or if can't write ch to +* unbuffered file, or if we flush a buffer but the number of wide chars +* written doesn't agree with buffer size. Otherwise returns ch. +* all fields in FILE struct can be affected except _file. +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _flswbuf ( + int ch, + FILE *str + ) + +#endif /* _UNICODE */ + +{ + + FILE *stream; + int charcount; + int written; + int fh; + + _ASSERTE(str != NULL); + + stream = str; + fh = _fileno(stream); + + if (!(stream->_flag & (_IOWRT|_IORW))) { + errno = EBADF; + stream->_flag |= _IOERR; + return(_TEOF); + } else if ((stream->_flag & _IOSTRG)) { + errno = ERANGE; + stream->_flag |= _IOERR; + return(_TEOF); + } + + /* Check that _IOREAD is not set or, if it is, then so is _IOEOF. Note + that _IOREAD and IOEOF both being set implies switching from read to + write at end-of-file, which is allowed by ANSI. Note that resetting + the _cnt and _ptr fields amounts to doing an fflush() on the stream + in this case. Note also that the _cnt field has to be reset to 0 for + the error path as well (i.e., _IOREAD set but _IOEOF not set) as + well as the non-error path. */ + + if (stream->_flag & _IOREAD) { + stream->_cnt = 0; + if (stream->_flag & _IOEOF) { + stream->_ptr = stream->_base; + stream->_flag &= ~_IOREAD; + } + else { + stream->_flag |= _IOERR; + return(_TEOF); + } + } + + stream->_flag |= _IOWRT; + stream->_flag &= ~_IOEOF; + written = charcount = stream->_cnt = 0; + + /* Get a buffer for this stream, if necessary. */ + if (!anybuf(stream)) { + + /* Do NOT get a buffer if (1) stream is stdout/stderr, and + (2) stream is NOT a tty. + [If stdout/stderr is a tty, we do NOT set up single char + buffering. This is so that later temporary buffering will + not be thwarted by the _IONBF bit being set (see + _stbuf/_ftbuf usage).] + */ + if (!( ((stream==stdout) || (stream==stderr)) + && (_isatty(fh)) )) + + _getbuf(stream); + + } /* end !anybuf() */ + + /* If big buffer is assigned to stream... */ + if (bigbuf(stream)) { + + _ASSERTE(("inconsistent IOB fields", stream->_ptr - stream->_base >= 0)); + + charcount = (int)(stream->_ptr - stream->_base); + stream->_ptr = stream->_base + sizeof(TCHAR); + stream->_cnt = stream->_bufsiz - (int)sizeof(TCHAR); + + if (charcount > 0) + written = _write(fh, stream->_base, charcount); + else + if (_osfile_safe(fh) & FAPPEND) + { + if( _lseeki64(fh,0L,SEEK_END)==-1) + { + stream->_flag |= _IOERR; + return(_TEOF); + } + } + +#ifndef _UNICODE + *stream->_base = (char)ch; +#else /* _UNICODE */ + *(wchar_t *)(stream->_base) = (wchar_t)(ch & 0xffff); +#endif /* _UNICODE */ + } + + /* Perform single character output (either _IONBF or no buffering) */ + else { + charcount = sizeof(TCHAR); +#ifndef _UNICODE + written = _write(fh, &ch, charcount); +#else /* _UNICODE */ + { + char mbc[4]; + + *(wchar_t *)mbc = (wchar_t)(ch & 0xffff); + written = _write(fh, mbc, charcount); + } +#endif /* _UNICODE */ + } + + /* See if the _write() was successful. */ + if (written != charcount) { + stream->_flag |= _IOERR; + return(_TEOF); + } + +#ifndef _UNICODE + return(ch & 0xff); +#else /* _UNICODE */ + return(ch & 0xffff); +#endif /* _UNICODE */ + +} diff --git a/test_data/lots_of_files/_flswbuf.c b/test_data/lots_of_files/_flswbuf.c new file mode 100644 index 0000000..9a59a87 --- /dev/null +++ b/test_data/lots_of_files/_flswbuf.c @@ -0,0 +1,23 @@ +/*** +*_flswbuf.c - flush buffer and output wide character. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _flswbuf() - flush a file buffer and output a wide character. +* If no buffer, make one. +* +*******************************************************************************/ + + + +#ifndef _UNICODE +#define _UNICODE 1 +#endif /* _UNICODE */ + +#ifndef UNICODE +#define UNICODE 1 +#endif /* UNICODE */ + +#include "_flsbuf.c" + diff --git a/test_data/lots_of_files/_fptostr.c b/test_data/lots_of_files/_fptostr.c new file mode 100644 index 0000000..a124c33 --- /dev/null +++ b/test_data/lots_of_files/_fptostr.c @@ -0,0 +1,109 @@ +/*** +*_fptostr.c - workhorse routine for converting floating point to string +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Workhorse routine for fcvt, ecvt. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <string.h> +#include <stddef.h> +#include <fltintrn.h> +#include <internal.h> + +/*** +*errno_t _fptostr(buf, size, digits, pflt) - workhorse floating point conversion +* +*Purpose: +* This is the workhorse routine for fcvt, ecvt. Here is where +* all the digits are put into a buffer and the rounding is +* performed and indicators of the decimal point position are set. Note, +* this must not change the mantissa field of pflt since routines which +* use this routine rely on this being unchanged. +* +*Entry: +* char *buf - the buffer in which the digits are to be put +* int digits - the number of digits which are to go into the buffer +* STRFLT pflt - a pointer to a structure containing information on the +* floating point value, including a string containing the +* non-zero significant digits of the mantissa. +* +*Exit: +* Changes the contents of the buffer and also may increment the decpt +* field of the structure pointer to by the 'pflt' parameter if overflow +* occurs during rounding (e.g. 9.999999... gets rounded to 10.000...). +* +*Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +errno_t __cdecl _fptostr ( + char *buf, + size_t sizeInBytes, + int digits, + STRFLT pflt + ) +{ + char *pbuf = buf; + char *mantissa = pflt->mantissa; + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(buf != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInBytes > 0, EINVAL); + buf[0] = '\0'; + /* the buffer will contains ndec decimal digits plus an optional + * overflow digit for the rounding + */ + _VALIDATE_RETURN_ERRCODE(sizeInBytes > (size_t)((digits > 0 ? digits : 0) + 1), ERANGE); + _VALIDATE_RETURN_ERRCODE(pflt != NULL, EINVAL); + + /* initialize the first digit in the buffer to '0' (NOTE - NOT '\0') + * and set the pointer to the second digit of the buffer. The first + * digit is used to handle overflow on rounding (e.g. 9.9999... + * becomes 10.000...) which requires a carry into the first digit. + */ + + *pbuf++ = '0'; + + /* Copy the digits of the value into the buffer (with 0 padding) + * and insert the terminating null character. + */ + + while (digits > 0) { + *pbuf++ = (*mantissa) ? *mantissa++ : (char)'0'; + digits--; + } + *pbuf = '\0'; + + /* do any rounding which may be needed. Note - if digits < 0 don't + * do any rounding since in this case, the rounding occurs in a digit + * which will not be output beause of the precision requested + */ + + if (digits >= 0 && *mantissa >= '5') { + pbuf--; + while (*pbuf == '9') + *pbuf-- = '0'; + *pbuf += 1; + } + + if (*buf == '1') { + /* the rounding caused overflow into the leading digit (e.g. + * 9.999.. went to 10.000...), so increment the decpt position + * by 1 + */ + pflt->decpt++; + } + else { + /* move the entire string to the left one digit to remove the + * unused overflow digit. + */ + memmove(buf, buf+1, strlen(buf+1)+1); + } + + return 0; +} diff --git a/test_data/lots_of_files/_freebuf.c b/test_data/lots_of_files/_freebuf.c new file mode 100644 index 0000000..8ad1d67 --- /dev/null +++ b/test_data/lots_of_files/_freebuf.c @@ -0,0 +1,56 @@ +/*** +*_freebuf.c - release a buffer from a stream +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _freebuf() - release a buffer from a stream +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <file2.h> +#include <dbgint.h> +#include <internal.h> +#include <stdlib.h> + +/*** +*void _freebuf(stream) - release a buffer from a stream +* +*Purpose: +* free a buffer if at all possible. free() the space if malloc'd by me. +* forget about trying to free a user's buffer for him; it may be static +* memory (not from malloc), so he has to take care of it. this function +* is not intended for use outside the library. +* +* Multi-thread notes: +* _freebuf() does NOT get the stream lock; it is assumed that the +* caller has already done this. +* +*Entry: +* FILE *stream - stream to free bufer on +* +*Exit: +* Buffer may be freed. +* No return value. +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _freebuf ( + FILE *stream + ) +{ + _ASSERTE(stream != NULL); + + if (inuse(stream) && mbuf(stream)) + { + _free_crt(stream->_base); + + stream->_flag &= ~(_IOMYBUF | _IOSETVBUF); + stream->_base = stream->_ptr = NULL; + stream->_cnt = 0; + } +} diff --git a/test_data/lots_of_files/_getbuf.c b/test_data/lots_of_files/_getbuf.c new file mode 100644 index 0000000..7d32061 --- /dev/null +++ b/test_data/lots_of_files/_getbuf.c @@ -0,0 +1,79 @@ +/*** +*_getbuf.c - Get a stream buffer +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Allocate a buffer and init stream data bases. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <file2.h> +#include <malloc.h> +#include <internal.h> +#include <dbgint.h> + +/*** +*_getbuf() - Allocate a buffer and init stream data bases +* +*Purpose: +* Allocates a buffer for a stream and inits the stream data bases. +* +* [NOTE 1: This routine assumes the caller has already checked to make +* sure the stream needs a buffer. +* +* [NOTE 2: Multi-thread - Assumes caller has aquired stream lock, if +* needed.] +* +*Entry: +* FILE *stream = stream to allocate a buffer for +* +*Exit: +* void +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _getbuf ( + FILE *str + ) +{ + FILE *stream; + + _ASSERTE(str != NULL); + +#if !defined (CRTDLL) + /* force library pre-termination procedure */ + _cflush++; +#endif /* !defined (CRTDLL) */ + + /* Init pointers */ + stream = str; + + + /* Try to get a big buffer */ + if (stream->_base = _malloc_crt(_INTERNAL_BUFSIZ)) + { + /* Got a big buffer */ + stream->_flag |= _IOMYBUF; + stream->_bufsiz = _INTERNAL_BUFSIZ; + } + + else { + + + /* Did NOT get a buffer - use single char buffering. */ + stream->_flag |= _IONBF; + stream->_base = (char *)&(stream->_charbuf); + stream->_bufsiz = 2; + + } + + stream->_ptr = stream->_base; + stream->_cnt = 0; + + return; +} diff --git a/test_data/lots_of_files/_mbslen.c b/test_data/lots_of_files/_mbslen.c new file mode 100644 index 0000000..4251ee9 --- /dev/null +++ b/test_data/lots_of_files/_mbslen.c @@ -0,0 +1,95 @@ +/*** +*_mbslen.c - Return number of multibyte characters in a multibyte string +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Return number of multibyte characters in a multibyte string +* excluding the terminal null. Locale-dependent. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdlib.h> +#include <locale.h> +#include <dbgint.h> +#include <ctype.h> +#include <mbctype.h> +#include <internal.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*_mbstrlen - Return number of multibyte characters in a multibyte string +* +*Purpose: +* Return number of multibyte characters in a multibyte string +* excluding the terminal null. Locale-dependent. +* +*Entry: +* char *s = string +* +*Exit: +* Returns the number of multibyte characters in the string, or +* Returns (size_t)-1 if the string contains an invalid multibyte character. +* Also, errno is set to EILSEQ. +* +*Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +size_t __cdecl _mbstrlen_l( + const char *s, + _locale_t plocinfo + ) +{ + size_t n; + _LocaleUpdate _loc_update(plocinfo); + + _ASSERTE (_loc_update.GetLocaleT()->locinfo->mb_cur_max == 1 || _loc_update.GetLocaleT()->locinfo->mb_cur_max == 2); + + if ( _loc_update.GetLocaleT()->locinfo->mb_cur_max == 1 ) + /* handle single byte character sets */ + return strlen(s); + + + /* verify all valid MB chars */ + if ( MultiByteToWideChar( _loc_update.GetLocaleT()->locinfo->lc_codepage, + MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, + s, + -1, + NULL, + 0 ) == 0 ) + { + /* bad MB char */ + errno = EILSEQ; + return (size_t)-1; + } + + /* count MB chars */ + for (n = 0; *s; n++, s++) { + if ( _isleadbyte_l((unsigned char)*s, _loc_update.GetLocaleT()) ) + { + if (*++s == '\0') + break; + } + } + + + return(n); +} + +size_t __cdecl _mbstrlen( + const char *s + ) +{ + if (__locale_changed == 0) + { + return strlen(s); + } + else + { + return _mbstrlen_l(s, NULL); + } +} diff --git a/test_data/lots_of_files/_mbslen_s.c b/test_data/lots_of_files/_mbslen_s.c new file mode 100644 index 0000000..a56209f --- /dev/null +++ b/test_data/lots_of_files/_mbslen_s.c @@ -0,0 +1,111 @@ +/*** +*_mbslen_s.c - Return number of multibyte characters in a multibyte string +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Return number of multibyte characters in a multibyte string +* excluding the terminal null. Locale-dependent. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdlib.h> +#include <ctype.h> +#include <locale.h> +#include <dbgint.h> +#include <internal.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*_mbstrnlen - Return number of multibyte characters in a multibyte string +* +*Purpose: +* Return number of multibyte characters in a multibyte string +* excluding the terminal null. Locale-dependent. +* +*Entry: +* char *s = string +* size_t maxsize +* +*Exit: +* Returns the number of multibyte characters in the string, or +* (size_t)-1 if the string contains an invalid multibyte character and errno +* is set to EILSEQ. +* Only the first sizeInBytes bytes of the string are inspected: if the null +* terminator is not found, sizeInBytes is returned. +* If the string is null terminated in sizeInBytes bytes, the return value +* will always be less than sizeInBytes. +* If something goes wrong, (size_t)-1 is returned and errno is set to EINVAL. +* +*Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +size_t __cdecl _mbstrnlen_l( + const char *s, + size_t sizeInBytes, + _locale_t plocinfo + ) +{ + size_t n, size; + + + /* validation section */ + _VALIDATE_RETURN(s != NULL, EINVAL, (size_t)-1); + _VALIDATE_RETURN(sizeInBytes <= INT_MAX, EINVAL, (size_t)-1); + + + _LocaleUpdate _loc_update(plocinfo); + + _ASSERTE (_loc_update.GetLocaleT()->locinfo->mb_cur_max == 1 || _loc_update.GetLocaleT()->locinfo->mb_cur_max == 2); + + if ( _loc_update.GetLocaleT()->locinfo->mb_cur_max == 1 ) + /* handle single byte character sets */ + return (int)strnlen(s, sizeInBytes); + + + /* verify all valid MB chars */ + if ( MultiByteToWideChar( _loc_update.GetLocaleT()->locinfo->lc_codepage, + MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, + s, + (int)sizeInBytes, + NULL, + 0 ) == 0 ) + { + /* bad MB char */ + errno = EILSEQ; + return (size_t)-1; + } + + /* count MB chars */ + /* Note that sizeInBytes here is the number of bytes, not mb characters! */ + for (n = 0, size = 0; size < sizeInBytes && *s; n++, s++, size++) + { + if ( _isleadbyte_l((unsigned char)*s, _loc_update.GetLocaleT()) ) + { + size++; + if (size >= sizeInBytes) + { + break; + } + if (*++s == '\0') + { + break; + } + } + } + + + return (size >= sizeInBytes ? sizeInBytes : n); +} + +size_t __cdecl _mbstrnlen( + const char *s, + size_t maxsize + ) +{ + return _mbstrnlen_l(s, maxsize, NULL); +} diff --git a/test_data/lots_of_files/_newmode.c b/test_data/lots_of_files/_newmode.c new file mode 100644 index 0000000..c4c1a8a --- /dev/null +++ b/test_data/lots_of_files/_newmode.c @@ -0,0 +1,31 @@ +/*** +*_newmode.c - set new() handler mode to not handle malloc failures +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Sets the global flag which controls whether the new() handler +* is called on malloc failures. The default behavior in Visual +* C++ v2.0 and later is not to, that malloc failures return NULL +* without calling the new handler. This object is linked in unless +* the special object NEWMODE.OBJ is manually linked. +* +* This source file is the complement of LINKOPTS/NEWMODE.C. +* +*******************************************************************************/ + + +#ifdef CRTDLL +#undef CRTDLL +#endif /* CRTDLL */ + +#ifdef MRTDLL +#undef MRTDLL +#endif /* MRTDLL */ + +#include <internal.h> + +/* enable new handler calls upon malloc failures */ + +int _newmode = 0; /* Malloc New Handler MODE */ + diff --git a/test_data/lots_of_files/_open.c b/test_data/lots_of_files/_open.c new file mode 100644 index 0000000..004ce60 --- /dev/null +++ b/test_data/lots_of_files/_open.c @@ -0,0 +1,289 @@ +/*** +*_open.c - open a stream, with string mode +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _openfile() - opens a stream, with string arguments for mode +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <file2.h> +#include <share.h> +#include <io.h> +#include <dbgint.h> +#include <internal.h> +#include <tchar.h> +#include <sys\stat.h> + +#define CMASK 0644 /* rw-r--r-- */ +#define P_CMASK 0666 /* different for Posix */ + +/*** +*FILE *_openfile(filename, mode, shflag, stream) - open a file with string +* mode and file sharing flag. +* +*Purpose: +* parse the string, looking for exactly one of {rwa}, at most one '+', +* at most one of {tb}, at most one of {cn}, at most one of {SR}, at most +* one 'T', and at most one 'D'. pass the result on as an int containing +* flags of what was found. open a file with proper mode if permissions +* allow. buffer not allocated until first i/o call is issued. intended +* for use inside library only +* +*Entry: +* char *filename - file to open +* char *mode - mode to use (see above) +* int shflag - file sharing flag +* FILE *stream - stream to use for file +* +*Exit: +* set stream's fields, and causes system file management by system calls +* returns stream or NULL if fails +* +*Exceptions: +* +*******************************************************************************/ + +FILE * __cdecl __topenfile ( + const _TSCHAR *filename, + const _TSCHAR *mode, + int shflag, + FILE *str + ) +{ + int modeflag = 0; + int streamflag = _commode; + int commodeset = 0; + int scanset = 0; + int whileflag; + int filedes; + FILE *stream; + BOOL encodingFlag = FALSE; + + _ASSERTE(filename != NULL); + _ASSERTE(mode != NULL); + _ASSERTE(str != NULL); + + /* Parse the user's specification string as set flags in + (1) modeflag - system call flags word + (2) streamflag - stream handle flags word. */ + + /* Skip leading spaces */ + while (*mode == _T(' ')) + { + ++mode; + } + + /* First mode character must be 'r', 'w', or 'a'. */ + + switch (*mode) { + case _T('r'): + modeflag = _O_RDONLY; + streamflag |= _IOREAD; + break; + case _T('w'): + modeflag = _O_WRONLY | _O_CREAT | _O_TRUNC; + streamflag |= _IOWRT; + break; + case _T('a'): + modeflag = _O_WRONLY | _O_CREAT | _O_APPEND; + streamflag |= _IOWRT; + break; + default: + _VALIDATE_RETURN(("Invalid file open mode",0), EINVAL, NULL); + } + + /* There can be up to three more optional mode characters: + (1) A single '+' character, + (2) One of 't' and 'b' and + (3) One of 'c' and 'n'. + */ + + whileflag=1; + + while(*++mode && whileflag) + switch(*mode) { + + case _T(' '): + /* skip spaces */ + break; + + case _T('+'): + if (modeflag & _O_RDWR) + whileflag=0; + else { + modeflag |= _O_RDWR; + modeflag &= ~(_O_RDONLY | _O_WRONLY); + streamflag |= _IORW; + streamflag &= ~(_IOREAD | _IOWRT); + } + break; + + case _T('b'): + if (modeflag & (_O_TEXT | _O_BINARY)) + whileflag=0; + else + modeflag |= _O_BINARY; + break; + + case _T('t'): + if (modeflag & (_O_TEXT | _O_BINARY)) + whileflag=0; + else + modeflag |= _O_TEXT; + break; + + case _T('c'): + if (commodeset) + whileflag=0; + else { + commodeset = 1; + streamflag |= _IOCOMMIT; + } + break; + + case _T('n'): + if (commodeset) + whileflag=0; + else { + commodeset = 1; + streamflag &= ~_IOCOMMIT; + } + break; + + case _T('S'): + if (scanset) + whileflag=0; + else { + scanset = 1; + modeflag |= _O_SEQUENTIAL; + } + break; + + case _T('R'): + if (scanset) + whileflag=0; + else { + scanset = 1; + modeflag |= _O_RANDOM; + } + break; + + case _T('T'): + if (modeflag & _O_SHORT_LIVED) + whileflag=0; + else + modeflag |= _O_SHORT_LIVED; + break; + + case _T('D'): + if (modeflag & _O_TEMPORARY) + whileflag=0; + else + modeflag |= _O_TEMPORARY; + break; + case _T('N'): + modeflag |= _O_NOINHERIT; + break; + + case _T(','): + encodingFlag = TRUE; + whileflag = 0; + break; + + + default: + _VALIDATE_RETURN(("Invalid file open mode",0), EINVAL, NULL); + } + if (encodingFlag) + { + static const _TSCHAR ccsField[] = _T("ccs"); + static const _TSCHAR utf8encoding[] = _T("UTF-8"); + static const _TSCHAR utf16encoding[] = _T("UTF-16LE"); + static const _TSCHAR unicodeencoding[] = _T("UNICODE"); + + /* Skip spaces */ + while (*mode == _T(' ')) + { + ++mode; + } + + /* + * The length that we want to compare is numbers of elements in + * csField -1 since this number also contains NULL terminator + */ + if (_tcsncmp(ccsField, mode, (_countof(ccsField))-1) != 0) + _VALIDATE_RETURN(("Invalid file open mode",0), EINVAL, NULL); + + mode += _countof(ccsField)-1; + + /* Skip spaces */ + while (*mode == _T(' ')) + { + ++mode; + } + + /* Look for '=' */ + if (*mode != _T('=')) + { + _VALIDATE_RETURN(("Invalid file open mode",0), EINVAL, NULL); + } + ++mode; + + /* Skip spaces */ + while (*mode == _T(' ')) + { + ++mode; + } + + if (_tcsnicmp(mode, utf8encoding, _countof(utf8encoding) - 1) == 0){ + mode += _countof(utf8encoding)-1; + modeflag |= _O_U8TEXT; + } + else if (_tcsnicmp(mode, utf16encoding, _countof(utf16encoding) - 1) == 0) { + mode += _countof(utf16encoding)-1; + modeflag |= _O_U16TEXT; + } + else if (_tcsnicmp(mode, unicodeencoding, _countof(unicodeencoding) - 1) == 0) { + mode += _countof(unicodeencoding)-1; + modeflag |= _O_WTEXT; + } + else + _VALIDATE_RETURN(("Invalid file open mode",0), EINVAL, NULL); + + } + + /* Skip trailing spaces */ + while (*mode == _T(' ')) + { + ++mode; + } + + _VALIDATE_RETURN( (*mode == _T('\0')), EINVAL, NULL); + + /* Try to open the file. Note that if neither 't' nor 'b' is + specified, _sopen will use the default. */ + + if (_tsopen_s(&filedes, filename, modeflag, shflag, _S_IREAD | _S_IWRITE) != 0) + return(NULL); + + /* Set up the stream data base. */ +#ifndef CRTDLL + _cflush++; /* force library pre-termination procedure */ +#endif /* CRTDLL */ + /* Init pointers */ + stream = str; + + stream->_flag = streamflag; + stream->_cnt = 0; + stream->_tmpfname = stream->_base = stream->_ptr = NULL; + + stream->_file = filedes; + + return(stream); +} diff --git a/test_data/lots_of_files/_setargv.c b/test_data/lots_of_files/_setargv.c new file mode 100644 index 0000000..82050a6 --- /dev/null +++ b/test_data/lots_of_files/_setargv.c @@ -0,0 +1,15 @@ +/*** +*_setargv.c - Wildcard argv[] expansion +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* _setargv performs wildcard argv[] expansion +* +* NOTE: This stub module scheme is compatible with NT build +* procedure. +* +*******************************************************************************/ + +#define WILDCARD 1 +#include "stdargv.c" diff --git a/test_data/lots_of_files/_sftbuf.c b/test_data/lots_of_files/_sftbuf.c new file mode 100644 index 0000000..92cd913 --- /dev/null +++ b/test_data/lots_of_files/_sftbuf.c @@ -0,0 +1,164 @@ +/*** +*_sftbuf.c - temporary buffering initialization and flushing +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* temporary buffering initialization and flushing. if stdout/err is +* unbuffered, buffer it temporarily so that string is sent to kernel as +* a batch of chars, not char-at-a-time. if appropriate, make buffering +* permanent. +* +* [NOTE 1: These routines assume that the temporary buffering is only +* used for output. In particular, note that _stbuf() sets _IOWRT.] +* +* [NOTE 2: It is valid for this module to assign a value directly to +* _flag instead of simply twiddling bits since we are initializing the +* buffer data base.] +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdio.h> +#include <file2.h> +#include <io.h> +#include <internal.h> +#include <malloc.h> +#include <mtdll.h> +#include <dbgint.h> + +/* Buffer pointers for stdout and stderr */ +void *_stdbuf[2] = { NULL, NULL}; + +/*** +*int _stbuf(stream) - set temp buffer on stdout, stdprn, stderr +* +*Purpose: +* if stdout/stderr is still unbuffered, buffer it. +* this function works intimately with _ftbuf, and accompanies it in +* bracketing normally unbuffered output. these functions intended for +* library use only. +* +* Multi-thread: It is assumed that the caller has already aquired the +* stream lock. +* +*Entry: +* FILE *stream - stream to temp buffer +* +*Exit: +* returns 1 if buffer initialized, 0 if not +* sets fields in stdout or stderr to indicate buffering +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _stbuf ( + FILE *str + ) +{ + FILE *stream; + int index; + + _ASSERTE(str != NULL); + + /* Init near stream pointer */ + stream = str; + + /* do nothing if not a tty device */ + if (!_isatty(_fileno(stream))) + return(0); + + /* Make sure stream is stdout/stderr and init _stdbuf index */ + if (stream == stdout) + index = 0; + else if (stream == stderr) + index = 1; + else + return(0); + +#ifndef CRTDLL + /* force library pre-termination procedure */ + _cflush++; +#endif /* CRTDLL */ + + /* Make sure the stream is not already buffered. */ + if (anybuf(stream)) + return(0); + + /* Allocate a buffer for this stream if we haven't done so yet. */ + if ( (_stdbuf[index] == NULL) && + ((_stdbuf[index]=_malloc_crt(_INTERNAL_BUFSIZ)) == NULL) ) { + /* Cannot allocate buffer. Use _charbuf this time */ + stream->_ptr = stream->_base = (void *)&(stream->_charbuf); + stream->_cnt = stream->_bufsiz = 2; + } + else { + /* Set up the buffer */ + stream->_ptr = stream->_base = _stdbuf[index]; + stream->_cnt = stream->_bufsiz = _INTERNAL_BUFSIZ; + } + + stream->_flag |= (_IOWRT | _IOYOURBUF | _IOFLRTN); + + return(1); +} + + +/*** +*void _ftbuf(flag, stream) - take temp buffering off a stream +* +*Purpose: +* If stdout/stderr is being buffered and it is a device, _flush and +* dismantle the buffer. if it's not a device, leave the buffering on. +* This function works intimately with _stbuf, and accompanies it in +* bracketing normally unbuffered output. these functions intended for +* library use only +* +* Multi-thread: It is assumed that the caller has already aquired the +* stream lock. +* +*Entry: +* int flag - a flag to tell whether to dismantle temp buffering on a +* stream +* FILE *stream - the stream +* +*Exit: +* no return value +* sets fields in stdout/stderr +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl _ftbuf ( + int flag, + FILE *str + ) +{ + FILE *stream; + + _ASSERTE(flag == 0 || flag == 1); + + /* Init near stream pointers */ + stream = str; + + if (flag) { + + if (stream->_flag & _IOFLRTN) { + + /* Flush the stream and tear down temp buffering. */ + _flush(stream); + stream->_flag &= ~(_IOYOURBUF | _IOFLRTN); + stream->_bufsiz = 0; + stream->_base = stream->_ptr = NULL; + } + + /* Note: If we expand the functionality of the _IOFLRTN bit to + include other streams, we may want to clear that bit here under + an 'else' clause (i.e., clear bit in the case that we leave the + buffer permanently assigned. Given our current use of the bit, + the extra code is not needed. */ + + } /* end flag = 1 */ +} diff --git a/test_data/lots_of_files/_strerr.c b/test_data/lots_of_files/_strerr.c new file mode 100644 index 0000000..e5051f0 --- /dev/null +++ b/test_data/lots_of_files/_strerr.c @@ -0,0 +1,153 @@ +/*** +*_strerr.c - routine for indexing into system error list +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Returns system error message index by errno; conforms to the +* XENIX standard, much compatibility with 1983 uniforum draft standard. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdlib.h> +#include <errmsg.h> +#include <syserr.h> +#include <string.h> +#include <tchar.h> +#include <malloc.h> +#include <mtdll.h> +#include <dbgint.h> +#include <internal.h> + +/* Max length of message = user_string(94)+system_string+2 */ +/* [NOTE: The mthread error message buffer is shared by both strerror + and _strerror so must be the max length of both. */ +#define _ERRMSGLEN_ (94+_SYS_MSGMAX+2) + +#ifdef _UNICODE +#define _terrmsg _werrmsg +#else /* _UNICODE */ +#define _terrmsg _errmsg +#endif /* _UNICODE */ + + +/*** +*char *_strerror(message) - get system error message +* +*Purpose: +* builds an error message consisting of the users error message +* (the message parameter), followed by ": ", followed by the system +* error message (index through errno), followed by a newline. If +* message is NULL or a null string, returns a pointer to just +* the system error message. +* +*Entry: +* char *message - user's message to prefix system error message +* +*Exit: +* returns pointer to static memory containing error message. +* returns NULL if malloc() fails in multi-thread versions. +* +*Exceptions: +* +*******************************************************************************/ + +#ifdef _UNICODE +wchar_t * __cdecl __wcserror( +#else /* _UNICODE */ +char * __cdecl _strerror ( +#endif /* _UNICODE */ + const _TCHAR *message + ) +{ + const char *sysErrorMsg = NULL; + _TCHAR *bldmsg; + _ptiddata ptd = _getptd_noexit(); + if (!ptd) + return NULL; + + /* Use per thread buffer area (malloc space, if necessary) */ + /* [NOTE: This buffer is shared between _strerror and streror.] */ + + if ( (ptd->_terrmsg == NULL) && ((ptd->_terrmsg = + _calloc_crt(_ERRMSGLEN_, sizeof(_TCHAR))) == NULL) ) + return(NULL); + bldmsg = ptd->_terrmsg; + + /* Build the error message */ + + bldmsg[0] = '\0'; + + if (message && *message) { + // should leave space for ": \n\0" + _ERRCHECK(_tcsncat_s( bldmsg, _ERRMSGLEN_, message, _ERRMSGLEN_-4 )); + _ERRCHECK(_tcscat_s( bldmsg, _ERRMSGLEN_, _T(": "))); + } + + // We should have extra space for "\n\0" + sysErrorMsg = _get_sys_err_msg(errno); + +#ifdef _UNICODE + _ERRCHECK(mbstowcs_s(NULL, bldmsg + wcslen(bldmsg), _ERRMSGLEN_ - wcslen(bldmsg), sysErrorMsg, _ERRMSGLEN_ - wcslen(bldmsg) - 2)); +#else /* _UNICODE */ + _ERRCHECK(strncat_s(bldmsg, _ERRMSGLEN_, sysErrorMsg, _ERRMSGLEN_ - strlen(bldmsg) - 2)); +#endif /* _UNICODE */ + + _ERRCHECK(_tcscat_s( bldmsg, _ERRMSGLEN_, _T("\n"))); + return bldmsg; +} + +/*** +*errno_t _strerror_s(buffer, sizeInTChars, message) - get system error message +* +*Purpose: +* builds an error message consisting of the users error message +* (the message parameter), followed by ": ", followed by the system +* error message (index through errno), followed by a newline. If +* message is NULL or a null string, returns a pointer to just +* the system error message. +* +*Entry: +* TCHAR * buffer - Destination buffer. +* size_t sizeInTChars - Size of the destination buffer. +* TCHAR * message - user's message to prefix system error message +* +*Exit: +* The error code. +* +*Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +#define _MIN_MSG_LENGTH 5 + +#ifdef _UNICODE +errno_t __cdecl __wcserror_s( +#else /* _UNICODE */ +errno_t __cdecl _strerror_s( +#endif /* _UNICODE */ + TCHAR* buffer, + size_t sizeInTChars, + const _TCHAR *message + ) +{ + errno_t e = 0; + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(buffer != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInTChars > 0, EINVAL); + buffer[0] = '\0'; + + if (message && + *message && + _tcslen(message) < (sizeInTChars - 2 - _MIN_MSG_LENGTH)) + { + _ERRCHECK(_tcscpy_s(buffer, sizeInTChars, message)); + _ERRCHECK(_tcscat_s(buffer, sizeInTChars, _T(": "))); + } + + /* append the error message at the end of the buffer */ + return _tcserror_s(buffer + _tcslen(buffer), sizeInTChars - _tcslen(buffer), errno); +} diff --git a/test_data/lots_of_files/_tolower.c b/test_data/lots_of_files/_tolower.c new file mode 100644 index 0000000..4f3f22f --- /dev/null +++ b/test_data/lots_of_files/_tolower.c @@ -0,0 +1,159 @@ +/*** +*_tolower.c - convert character to lower case +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines _Tolower(). +* +*******************************************************************************/ + +#include <cruntime.h> +#include <ctype.h> +#include <stddef.h> +#include <xlocinfo.h> +#include <locale.h> +#include <mtdll.h> +#include <setlocal.h> +#include <awint.h> +#include <stdlib.h> +#include <dbgint.h> +#include <yvals.h> + +/* remove macro definitions of _tolower() and tolower() + */ +#undef _tolower +#undef tolower + +/*** +*int _Tolower(c) - convert character to lower case +* +*Purpose: +* _Tolower() is a version of tolower with a locale argument. +* +*Entry: +* c - int value of character to be converted +* const _Ctypevec * = pointer to locale info +* +*Exit: +* returns int value of lower case representation of c +* +*Exceptions: +* +*******************************************************************************/ + +_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Tolower ( + int c, + const _Ctypevec *ploc + ) +{ + int size; + unsigned char inbuffer[3]; + unsigned char outbuffer[3]; + + UINT codepage; + const wchar_t *locale_name; + + if (ploc == 0) + { + locale_name = ___lc_locale_name_func()[LC_CTYPE]; + codepage = ___lc_codepage_func(); + } + else + { + locale_name = ploc->_LocaleName; + codepage = ploc->_Page; + } + + if (locale_name == NULL) + { + if ( (c >= 'A') && (c <= 'Z') ) + c = c + ('a' - 'A'); + return c; + } + + /* if checking case of c does not require API call, do it */ + if ((unsigned)c < 256) + { + if (ploc == 0) + { + if (!isupper(c)) + { + return c; + } + } + else + { + if (!(ploc->_Table[c] & _UPPER)) + { + return c; + } + } + } + + /* convert int c to multibyte string */ + if (ploc == 0 ? _cpp_isleadbyte((c >> 8) & 0xff) + : (ploc->_Table[(c >> 8) & 0xff] & _LEADBYTE) != 0) + { + inbuffer[0] = (c >> 8 & 0xff); + inbuffer[1] = (unsigned char)c; + inbuffer[2] = 0; + size = 2; + } else { + inbuffer[0] = (unsigned char)c; + inbuffer[1] = 0; + size = 1; + } + + /* convert wide char to lowercase */ + if (0 == (size = __crtLCMapStringA(NULL, locale_name, LCMAP_LOWERCASE, + (const char *)inbuffer, size, (char *)outbuffer, 3, codepage, TRUE))) + { + return c; + } + + /* construct integer return value */ + if (size == 1) + return ((int)outbuffer[0]); + else + return ((int)outbuffer[1] | ((int)outbuffer[0] << 8)); + +} + + +/*** +*_Ctypevec _Getctype() - get ctype info for current locale +* +*Purpose: +* +*Entry: +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +_CRTIMP2_PURE _Ctypevec __CLRCALL_PURE_OR_CDECL _Getctype() +{ + /* get ctype info for current locale */ + _Ctypevec ctype; + + ctype._Page = ___lc_codepage_func(); + ctype._Table = (const short *)_calloc_crt(256, sizeof (*__pctype_func())); + if (ctype._Table != 0) + { + memcpy((void *)ctype._Table, __pctype_func(), 256 * sizeof (*__pctype_func())); + ctype._Delfl = 1; + } + else + { + ctype._Table = (const short *)__pctype_func(); + ctype._Delfl = 0; + } + ctype._LocaleName = ___lc_locale_name_func()[LC_COLLATE]; + if (ctype._LocaleName) + ctype._LocaleName = _wcsdup(ctype._LocaleName); + + return (ctype); +} diff --git a/test_data/lots_of_files/_toupper.c b/test_data/lots_of_files/_toupper.c new file mode 100644 index 0000000..d251b0e --- /dev/null +++ b/test_data/lots_of_files/_toupper.c @@ -0,0 +1,119 @@ +/*** +*_toupper.c - convert character to uppercase +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines _Toupper() +* +*******************************************************************************/ + +#include <cruntime.h> +#include <ctype.h> +#include <stddef.h> +#include <xlocinfo.h> +#include <locale.h> +#include <mtdll.h> +#include <setlocal.h> +#include <awint.h> +#include <yvals.h> + +/* remove macro definitions of _toupper() and toupper() + */ +#undef _toupper +#undef toupper + +/*** +*int _Toupper(c) - convert character to uppercase +* +*Purpose: +* _Toupper() is a version of toupper with a locale argument. +* +*Entry: +* c - int value of character to be converted +* const _Ctypevec * = pointer to locale info +* +*Exit: +* returns int value of uppercase representation of c +* +*Exceptions: +* +*******************************************************************************/ + +_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Toupper ( + int c, + const _Ctypevec *ploc + ) +{ + int size; + unsigned char inbuffer[3]; + unsigned char outbuffer[3]; + + const wchar_t *locale_name; + UINT codepage; + + if (ploc == 0) + { + locale_name = ___lc_locale_name_func()[LC_CTYPE]; + codepage = ___lc_codepage_func(); + } + else + { + locale_name = ploc->_LocaleName; + codepage = ploc->_Page; + } + + if (locale_name == NULL) + { + if ( (c >= 'a') && (c <= 'z') ) + c = c - ('a' - 'A'); + return c; + } + + /* if checking case of c does not require API call, do it */ + if ((unsigned)c < 256) + { + if (ploc == 0) + { + if (!islower(c)) + { + return c; + } + } + else + { + if (!(ploc->_Table[c] & _LOWER)) + { + return c; + } + } + } + + /* convert int c to multibyte string */ + if (ploc == 0 ? _cpp_isleadbyte((c >> 8) & 0xff) + : (ploc->_Table[(c >> 8) & 0xff] & _LEADBYTE) != 0) + { + inbuffer[0] = (c >> 8 & 0xff); + inbuffer[1] = (unsigned char)c; + inbuffer[2] = 0; + size = 2; + } else { + inbuffer[0] = (unsigned char)c; + inbuffer[1] = 0; + size = 1; + } + + /* convert wide char to uppercase */ + if (0 == (size = __crtLCMapStringA(NULL, locale_name, LCMAP_UPPERCASE, + (const char *)inbuffer, size, (char *)outbuffer, 3, codepage, TRUE))) + { + return c; + } + + /* construct integer return value */ + if (size == 1) + return ((int)outbuffer[0]); + else + return ((int)outbuffer[1] | ((int)outbuffer[0] << 8)); + +} diff --git a/test_data/lots_of_files/_wcserr.c b/test_data/lots_of_files/_wcserr.c new file mode 100644 index 0000000..8a1fa49 --- /dev/null +++ b/test_data/lots_of_files/_wcserr.c @@ -0,0 +1,26 @@ +/*** +*_wcserr.c - routine for indexing into system error list +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Returns system error message index by errno; conforms to the +* XENIX standard, much compatibility with 1983 uniforum draft standard. +* (wide char version of _strerror()) +* +*******************************************************************************/ + + +#ifndef _UNICODE +#define _UNICODE 1 +#endif /* _UNICODE */ + +#ifndef UNICODE +#define UNICODE 1 +#endif /* UNICODE */ + +#undef _MBCS /* UNICODE not _MBCS */ + +#include "_strerr.c" + + diff --git a/test_data/lots_of_files/_wctype.c b/test_data/lots_of_files/_wctype.c new file mode 100644 index 0000000..b074a97 --- /dev/null +++ b/test_data/lots_of_files/_wctype.c @@ -0,0 +1,284 @@ +/*** +*_wctype.c - function versions of wctype macros +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file provides function versions of the wide character +* classification and conversion macros in ctype.h. +* +*******************************************************************************/ + + +/*** +*wctype - Function versions of wctype macros +* +*Purpose: +* Function versions of the wide char macros in ctype.h, +* including isleadbyte and iswascii. In order to define +* these, we use a trick -- we undefine the macro so we can use the +* name in the function declaration, then re-include the file so +* we can use the macro in the definition part. +* +* Functions defined: +* iswalpha iswupper iswlower +* iswdigit iswxdigit iswspace +* iswpunct iswalnum iswprint +* iswgraph iswctrl iswascii +* iswblank isleadbyte +* +*Entry: +* wchar_t c = character to be tested +*Exit: +* returns non-zero = character is of the requested type +* 0 = character is NOT of the requested type +* +*Exceptions: +* None. +* +*******************************************************************************/ + +#include <ctype.h> +#include <cruntime.h> +#include <stdlib.h> +#include <locale.h> +#include <mbctype.h> +#include <mtdll.h> +#include <setlocal.h> + +extern "C" +{ +extern __inline int (__cdecl _isleadbyte_l) ( + int c, + _locale_t plocinfo + ) +{ + _LocaleUpdate _loc_update(plocinfo); + return (_loc_update.GetLocaleT()->locinfo->pctype[(unsigned char)(c)] & _LEADBYTE); +} + +extern __inline int (__cdecl isleadbyte) ( + int c + ) +{ + return _isleadbyte_l(c, NULL); +} + +extern __inline int (__cdecl _iswalpha_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswalpha(c); +} + +extern __inline int (__cdecl iswalpha) ( + wint_t c + ) +{ + return iswalpha(c); +} + +extern __inline int (__cdecl _iswupper_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswupper(c); +} + +extern __inline int (__cdecl iswupper) ( + wint_t c + ) +{ + return iswupper(c); +} + +extern __inline int (__cdecl _iswlower_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswlower(c); +} + +extern __inline int (__cdecl iswlower) ( + wint_t c + ) +{ + return iswlower(c); +} + +extern __inline int (__cdecl _iswdigit_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswdigit(c); +} + +extern __inline int (__cdecl iswdigit) ( + wint_t c + ) +{ + return iswdigit(c); +} + +extern __inline int (__cdecl _iswxdigit_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswxdigit(c); +} + +extern __inline int (__cdecl iswxdigit) ( + wint_t c + ) +{ + return iswxdigit(c); +} + +extern __inline int (__cdecl _iswspace_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswspace(c); +} + +extern __inline int (__cdecl iswspace) ( + wint_t c + ) +{ + return iswspace(c); +} + +extern __inline int (__cdecl _iswpunct_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswpunct(c); +} + +extern __inline int (__cdecl iswpunct) ( + wint_t c + ) +{ + return iswpunct(c); +} + +extern __inline int (__cdecl _iswblank_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswblank(c); +} + +extern __inline int (__cdecl iswblank) ( + wint_t c + ) +{ + return iswblank(c); +} + +extern __inline int (__cdecl _iswalnum_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswalnum(c); +} + +extern __inline int (__cdecl iswalnum) ( + wint_t c + ) +{ + return iswalnum(c); +} + +extern __inline int (__cdecl _iswprint_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswprint(c); +} + +extern __inline int (__cdecl iswprint) ( + wint_t c + ) +{ + return iswprint(c); +} + +extern __inline int (__cdecl _iswgraph_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswgraph(c); +} + +extern __inline int (__cdecl iswgraph) ( + wint_t c + ) +{ + return iswgraph(c); +} + +extern __inline int (__cdecl _iswcntrl_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return iswcntrl(c); +} + +extern __inline int (__cdecl iswcntrl) ( + wint_t c + ) +{ + return iswcntrl(c); +} + +extern __inline int (__cdecl iswascii) ( + wint_t c + ) +{ + return iswascii(c); +} + +extern __inline int (__cdecl _iswcsym_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return __iswcsym(c); +} + +extern __inline int (__cdecl __iswcsym) ( + wint_t c + ) +{ + return __iswcsym(c); +} + +extern __inline int (__cdecl _iswcsymf_l) ( + wint_t c, + _locale_t plocinfo + ) +{ + return __iswcsymf(c); +} + +extern __inline int (__cdecl __iswcsymf) ( + wint_t c + ) +{ + return __iswcsymf(c); +} + +} diff --git a/test_data/lots_of_files/_wopen.c b/test_data/lots_of_files/_wopen.c new file mode 100644 index 0000000..ce56eed --- /dev/null +++ b/test_data/lots_of_files/_wopen.c @@ -0,0 +1,21 @@ +/*** +*_wopen.c - open a stream, with string mode (wchar_t version) +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _wopenfile() - opens a stream, with string arguments for mode +* +*******************************************************************************/ + + +#ifndef _UNICODE +#define _UNICODE 1 +#endif /* _UNICODE */ + +#ifndef UNICODE +#define UNICODE 1 +#endif /* UNICODE */ + +#include "_open.c" + diff --git a/test_data/lots_of_files/_wstargv.c b/test_data/lots_of_files/_wstargv.c new file mode 100644 index 0000000..e75acd2 --- /dev/null +++ b/test_data/lots_of_files/_wstargv.c @@ -0,0 +1,30 @@ +/*** +*_wstargv.c - Wildcard argv[] expansion (wchar_t version) +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* _wsetargv performs wildcard argv[] expansion +* +* NOTE: This stub module scheme is compatible with NT build +* procedure. +* +*******************************************************************************/ + + +#define WPRFLAG 1 + +#ifndef _UNICODE +#define _UNICODE 1 +#endif /* _UNICODE */ + +#ifndef UNICODE +#define UNICODE 1 +#endif /* UNICODE */ + +#undef _MBCS /* UNICODE not _MBCS */ + +#define WILDCARD 1 + +#include "stdargv.c" + diff --git a/test_data/lots_of_files/a_cmp.c b/test_data/lots_of_files/a_cmp.c new file mode 100644 index 0000000..20fd857 --- /dev/null +++ b/test_data/lots_of_files/a_cmp.c @@ -0,0 +1,279 @@ +/*** +*a_cmp.c - A version of CompareString. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Use either CompareStringA or CompareStringW depending on which is +* available +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <dbgint.h> +#include <stdlib.h> +#include <locale.h> +#include <awint.h> +#include <dbgint.h> +#include <malloc.h> +#include <awint.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*int __cdecl strncnt - count characters in a string, up to n. +* +*Purpose: +* Internal local support function. Counts characters in string before NULL. +* If NULL not found in n chars, then return n. +* +*Entry: +* const char *string - start of string +* int n - byte count +* +*Exit: +* returns number of bytes from start of string to +* NULL (exclusive), up to n. +* +*Exceptions: +* +*******************************************************************************/ + +static int __cdecl strncnt ( + const char *string, + int cnt + ) +{ + int n = cnt; + char *cp = (char *)string; + + while (n-- && *cp) + cp++; + + return cnt - n - 1; +} + +/*** +*int __cdecl __crtCompareStringA - Get type information about an ANSI string. +* +*Purpose: +* Internal support function. Assumes info in ANSI string format. Tries +* to use NLS API call CompareStringA if available and uses CompareStringW +* if it must. If neither are available it fails and returns 0. +* +*Entry: +* LPCWSTR LocaleName - locale context for the comparison. +* DWORD dwCmpFlags - see NT\Chicago docs +* LPCSTR lpStringn - multibyte string to be compared +* int cchCountn - char (byte) count (NOT including NULL) +* (-1 if NULL terminated) +* int code_page - for MB/WC conversion. If 0, use __lc_codepage +* +*Exit: +* Success: 1 - if lpString1 < lpString2 +* 2 - if lpString1 == lpString2 +* 3 - if lpString1 > lpString2 +* Failure: 0 +* +*Exceptions: +* +*******************************************************************************/ + +static int __cdecl __crtCompareStringA_stat( + _locale_t plocinfo, + LPCWSTR LocaleName, + DWORD dwCmpFlags, + LPCSTR lpString1, + int cchCount1, + LPCSTR lpString2, + int cchCount2, + int code_page + ) +{ + /* + * CompareString will compare past NULL. Must find NULL if in string + * before cchCountn chars. + */ + + if (cchCount1 > 0) + cchCount1 = strncnt(lpString1, cchCount1); + else if ( cchCount1 < -1 ) + return FALSE; + if (cchCount2 > 0) + cchCount2 = strncnt(lpString2, cchCount2); + else if ( cchCount2 < -1 ) + return FALSE; + + + int buff_size1; + int buff_size2; + wchar_t *wbuffer1; + wchar_t *wbuffer2; + int retcode = 0; + + /* + * Use __lc_codepage for conversion if code_page not specified + */ + + if (0 == code_page) + code_page = plocinfo->locinfo->lc_codepage; + + /* + * Special case: at least one count is zero + */ + + if (!cchCount1 || !cchCount2) + { + unsigned char *cp; // char pointer + CPINFO cpInfo; // struct for use with GetCPInfo + + /* both strings zero */ + if (cchCount1 == cchCount2) + return 2; + + /* string 1 greater */ + if (cchCount2 > 1) + return 1; + + /* string 2 greater */ + if (cchCount1 > 1) + return 3; + + /* + * one has zero count, the other has a count of one + * - if the one count is a naked lead byte, the strings are equal + * - otherwise it is a single character and they are unequal + */ + + if (GetCPInfo(code_page, &cpInfo) == FALSE) + return 0; + + _ASSERTE(cchCount1==0 && cchCount2==1 || cchCount1==1 && cchCount2==0); + + /* string 1 has count of 1 */ + if (cchCount1 > 0) + { + if (cpInfo.MaxCharSize < 2) + return 3; + + for ( cp = (unsigned char *)cpInfo.LeadByte ; + cp[0] && cp[1] ; + cp += 2 ) + if ( (*(unsigned char *)lpString1 >= cp[0]) && + (*(unsigned char *)lpString1 <= cp[1]) ) + return 2; + + return 3; + } + + /* string 2 has count of 1 */ + if (cchCount2 > 0) + { + if (cpInfo.MaxCharSize < 2) + return 1; + + for ( cp = (unsigned char *)cpInfo.LeadByte ; + cp[0] && cp[1] ; + cp += 2 ) + if ( (*(unsigned char *)lpString2 >= cp[0]) && + (*(unsigned char *)lpString2 <= cp[1]) ) + return 2; + + return 1; + } + } + + /* + * Convert strings and return the requested information. + */ + + /* find out how big a buffer we need (includes NULL if any) */ + if ( 0 == (buff_size1 = MultiByteToWideChar( code_page, + MB_PRECOMPOSED | + MB_ERR_INVALID_CHARS, + lpString1, + cchCount1, + NULL, + 0 )) ) + return 0; + + /* allocate enough space for chars */ + wbuffer1 = (wchar_t *)_calloca( buff_size1, sizeof(wchar_t) ); + if ( wbuffer1 == NULL ) { + return 0; + } + + /* do the conversion */ + if ( 0 == MultiByteToWideChar( code_page, + MB_PRECOMPOSED, + lpString1, + cchCount1, + wbuffer1, + buff_size1 ) ) + goto error_cleanup; + + /* find out how big a buffer we need (includes NULL if any) */ + if ( 0 == (buff_size2 = MultiByteToWideChar( code_page, + MB_PRECOMPOSED | + MB_ERR_INVALID_CHARS, + lpString2, + cchCount2, + NULL, + 0 )) ) + goto error_cleanup; + + /* allocate enough space for chars */ + wbuffer2 = (wchar_t *)_calloca( buff_size2, sizeof(wchar_t) ); + if ( wbuffer2 == NULL ) { + goto error_cleanup; + } + + /* do the conversion */ + if ( 0 != MultiByteToWideChar( code_page, + MB_PRECOMPOSED, + lpString2, + cchCount2, + wbuffer2, + buff_size2 ) ) + { + retcode = __crtCompareStringEx( LocaleName, + dwCmpFlags, + wbuffer1, + buff_size1, + wbuffer2, + buff_size2); + } + + _freea(wbuffer2); + +error_cleanup: + _freea(wbuffer1); + + return retcode; +} + +extern "C" int __cdecl __crtCompareStringA( + _locale_t plocinfo, + LPCWSTR LocaleName, + DWORD dwCmpFlags, + LPCSTR lpString1, + int cchCount1, + LPCSTR lpString2, + int cchCount2, + int code_page + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return __crtCompareStringA_stat( + _loc_update.GetLocaleT(), + LocaleName, + dwCmpFlags, + lpString1, + cchCount1, + lpString2, + cchCount2, + code_page + ); +} diff --git a/test_data/lots_of_files/a_env.c b/test_data/lots_of_files/a_env.c new file mode 100644 index 0000000..ed0e639 --- /dev/null +++ b/test_data/lots_of_files/a_env.c @@ -0,0 +1,96 @@ +/*** +*a_env.c - A version of GetEnvironmentStrings. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Use GetEnvironmentStringsW if available, otherwise use A version. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <stdlib.h> +#include <setlocal.h> +#include <awint.h> +#include <dbgint.h> + +/*** +*LPVOID __cdecl __crtGetEnvironmentStringsA - Get normal environment block +* +*Purpose: +* Internal support function. Since GetEnvironmentStrings returns in OEM +* and we want ANSI (note that GetEnvironmentVariable returns ANSI!) and +* SetFileApistoAnsi() does not affect it, we have no choice but to +* obtain the block in wide character and convert to ANSI. +* +*Entry: +* VOID +* +*Exit: +* LPVOID - pointer to environment block +* +*Exceptions: +* +*******************************************************************************/ + +LPVOID __cdecl __crtGetEnvironmentStringsA( + VOID + ) +{ + wchar_t *wEnv; + wchar_t *wTmp; + char *aEnv = NULL; + int nSizeW; + int nSizeA; + + /* obtain wide environment block */ + + if ( NULL == (wEnv = GetEnvironmentStringsW()) ) + return NULL; + + /* look for double null that indicates end of block */ + wTmp = wEnv; + while ( *wTmp != L'\0' ) { + if ( *++wTmp == L'\0' ) + wTmp++; + } + + /* calculate total size of block, including all nulls */ + nSizeW = (int)(wTmp - wEnv + 1); + + /* find out how much space needed for multi-byte environment */ + nSizeA = WideCharToMultiByte( CP_ACP, + 0, + wEnv, + nSizeW, + NULL, + 0, + NULL, + NULL ); + + /* allocate space for multi-byte string */ + if ( (nSizeA == 0) || + ((aEnv = (char *)_malloc_crt(nSizeA)) == NULL) ) + { + FreeEnvironmentStringsW( wEnv ); + return NULL; + } + + /* do the conversion */ + if ( !WideCharToMultiByte( CP_ACP, + 0, + wEnv, + nSizeW, + aEnv, + nSizeA, + NULL, + NULL ) ) + { + _free_crt( aEnv ); + aEnv = NULL; + } + + FreeEnvironmentStringsW( wEnv ); + return aEnv; +} diff --git a/test_data/lots_of_files/a_loc.c b/test_data/lots_of_files/a_loc.c new file mode 100644 index 0000000..ffcf3c2 --- /dev/null +++ b/test_data/lots_of_files/a_loc.c @@ -0,0 +1,130 @@ +/*** +*a_loc.c - A versions of GetLocaleInfo. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Use either GetLocaleInfoA or GetLocaleInfoW depending on which is +* available +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <stdlib.h> +#include <awint.h> +#include <dbgint.h> +#include <malloc.h> +#include <locale.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*int __cdecl __crtGetLocaleInfoA - Get locale info and return it as an ASCII +* string +* +*Purpose: +* Internal support function. Assumes info in ANSI string format. Tries +* to use NLS API call GetLocaleInfoA if available (Chicago) and uses +* GetLocaleInfoA if it must (NT). If neither are available it fails and +* returns 0. +* +*Entry: +* LPCWSTR LocaleName - locale context for the comparison. +* LCTYPE LCType - see NT\Chicago docs +* LPSTR lpLCData - pointer to memory to return data +* int cchData - char (byte) count of buffer (including NULL) +* (if 0, lpLCData is not referenced, size needed +* is returned) +* int code_page - for MB/WC conversion. If 0, use __lc_codepage +* +*Exit: +* Success: the number of characters copied (including NULL). +* Failure: 0 +* +*Exceptions: +* +*******************************************************************************/ + +static int __cdecl __crtGetLocaleInfoA_stat( + _locale_t plocinfo, + const wchar_t* LocaleName, + LCTYPE LCType, + LPSTR lpLCData, + int cchData + ) +{ + int retval = 0; + int code_page; + int buff_size; + wchar_t *wbuffer; + + /* + * Use __lc_codepage for conversion + */ + + code_page = plocinfo->locinfo->lc_codepage; + + /* find out how big buffer needs to be */ + if (0 == (buff_size = __crtGetLocaleInfoEx(LocaleName, LCType, NULL, 0))) + return 0; + + /* allocate buffer */ + wbuffer = (wchar_t *)_calloca( buff_size, sizeof(wchar_t) ); + if ( wbuffer == NULL ) { + return 0; + } + + /* get the info in wide format */ + if (0 == __crtGetLocaleInfoEx(LocaleName, LCType, wbuffer, buff_size)) + goto error_cleanup; + + /* convert from Wide Char to ANSI */ + if (0 == cchData) + { + /* convert into local buffer */ + retval = WideCharToMultiByte( code_page, + 0, + wbuffer, + -1, + NULL, + 0, + NULL, + NULL ); + } + else { + /* convert into user buffer */ + retval = WideCharToMultiByte( code_page, + 0, + wbuffer, + -1, + lpLCData, + cchData, + NULL, + NULL ); + } + +error_cleanup: + _freea(wbuffer); + + return retval; +} + +extern "C" int __cdecl __crtGetLocaleInfoA( + _locale_t plocinfo, + const wchar_t* LocaleName, + LCTYPE LCType, + LPSTR lpLCData, + int cchData + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return __crtGetLocaleInfoA_stat( + _loc_update.GetLocaleT(), + LocaleName, + LCType, + lpLCData, + cchData + ); +} diff --git a/test_data/lots_of_files/a_map.c b/test_data/lots_of_files/a_map.c new file mode 100644 index 0000000..ff9940b --- /dev/null +++ b/test_data/lots_of_files/a_map.c @@ -0,0 +1,272 @@ +/*** +*a_map.c - A version of LCMapString. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Use either LCMapStringA or LCMapStringW depending on which is available +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <stdlib.h> +#include <locale.h> +#include <awint.h> +#include <dbgint.h> +#include <malloc.h> +#include <locale.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*int __cdecl strncnt - count characters in a string, up to n. +* +*Purpose: +* Internal local support function. Counts characters in string before +* null. If null is not found in n chars, then return n. +* +*Entry: +* const char *string - start of string +* int n - byte count +* +*Exit: +* returns number of bytes from start of string to +* null (exclusive), up to n. +* +*Exceptions: +* +*******************************************************************************/ + +static int __cdecl strncnt ( + const char *string, + int cnt + ) +{ + int n = cnt; + char *cp = (char *)string; + + while (n-- && *cp) + cp++; + + return cnt - n - 1; +} + + +/*** +*int __cdecl __crtLCMapStringA - Get type information about an ANSI string. +* +*Purpose: +* Internal support function. Assumes info in ANSI string format. Tries +* to use NLS API call LCMapStringA if available and uses LCMapStringW +* if it must. If neither are available it fails and returns 0. +* +*Entry: +* LPCWSTR LocaleName - locale context for the comparison. +* DWORD dwMapFlags - see NT\Chicago docs +* LPCSTR lpSrcStr - pointer to string to be mapped +* int cchSrc - wide char (word) count of input string +* (including NULL if any) +* (-1 if NULL terminated) +* LPSTR lpDestStr - pointer to memory to store mapping +* int cchDest - char (byte) count of buffer (including NULL) +* int code_page - for MB/WC conversion. If 0, use __lc_codepage +* BOOL bError - TRUE if MB_ERR_INVALID_CHARS set on call to +* MultiByteToWideChar when GetStringTypeW used. +* +*Exit: +* Success: number of chars written to lpDestStr (including NULL) +* Failure: 0 +* +*Exceptions: +* +*******************************************************************************/ + +static int __cdecl __crtLCMapStringA_stat( + _locale_t plocinfo, + LPCWSTR LocaleName, + DWORD dwMapFlags, + LPCSTR lpSrcStr, + int cchSrc, + LPSTR lpDestStr, + int cchDest, + int code_page, + BOOL bError + ) +{ + /* + * LCMapString will map past NULL. Must find NULL if in string + * before cchSrc characters. + */ + if (cchSrc > 0) { + int cchSrcCnt = strncnt(lpSrcStr, cchSrc); + /* + * Include NULL in cchSrc if lpSrcStr terminated within cchSrc bytes. + */ + if (cchSrcCnt < cchSrc) { + cchSrc = cchSrcCnt + 1; + } else { + cchSrc = cchSrcCnt; + } + } + + int retval = 0; + int inbuff_size; + int outbuff_size; + wchar_t *inwbuffer = NULL; + wchar_t *outwbuffer = NULL; + + /* + * Convert string and return the requested information. Note that + * we are converting to a wide string so there is not a + * one-to-one correspondence between number of wide chars in the + * input string and the number of *bytes* in the buffer. However, + * there had *better be* a one-to-one correspondence between the + * number of wide characters and the number of multibyte characters + * or the resulting mapped string will be worthless to the user. + */ + + /* + * Use __lc_codepage for conversion if code_page not specified + */ + + if (0 == code_page) + code_page = plocinfo->locinfo->lc_codepage; + + /* find out how big a buffer we need (includes NULL if any) */ + if ( 0 == (inbuff_size = + MultiByteToWideChar( code_page, + bError ? MB_PRECOMPOSED | + MB_ERR_INVALID_CHARS : + MB_PRECOMPOSED, + lpSrcStr, + cchSrc, + NULL, + 0 )) ) + return 0; + + /* allocate enough space for wide chars */ + inwbuffer = (wchar_t *)_calloca( inbuff_size, sizeof(wchar_t) ); + if ( inwbuffer == NULL ) { + return 0; + } + + /* do the conversion */ + if ( 0 == MultiByteToWideChar( code_page, + MB_PRECOMPOSED, + lpSrcStr, + cchSrc, + inwbuffer, + inbuff_size) ) + goto error_cleanup; + + /* get size required for string mapping */ + if ( 0 == (retval = __crtLCMapStringEx( LocaleName, + dwMapFlags, + inwbuffer, + inbuff_size, + NULL, + 0)) ) + goto error_cleanup; + + if (dwMapFlags & LCMAP_SORTKEY) { + /* retval is size in BYTES */ + + if (0 != cchDest) { + + if (retval > cchDest) + goto error_cleanup; + + /* do string mapping */ + if ( 0 == __crtLCMapStringEx( LocaleName, + dwMapFlags, + inwbuffer, + inbuff_size, + (LPWSTR)lpDestStr, + cchDest) ) + goto error_cleanup; + } + } + else { + /* retval is size in wide chars */ + + outbuff_size = retval; + + /* allocate enough space for wide chars (includes NULL if any) */ + outwbuffer = (wchar_t *)_calloca( outbuff_size, sizeof(wchar_t) ); + if ( outwbuffer == NULL ) { + goto error_cleanup; + } + + /* do string mapping */ + if ( 0 == __crtLCMapStringEx( LocaleName, + dwMapFlags, + inwbuffer, + inbuff_size, + outwbuffer, + outbuff_size) ) + goto error_cleanup; + + if (0 == cchDest) { + /* get size required */ + if ( 0 == (retval = + WideCharToMultiByte( code_page, + 0, + outwbuffer, + outbuff_size, + NULL, + 0, + NULL, + NULL )) ) + goto error_cleanup; + } + else { + /* convert mapping */ + if ( 0 == (retval = + WideCharToMultiByte( code_page, + 0, + outwbuffer, + outbuff_size, + lpDestStr, + cchDest, + NULL, + NULL )) ) + goto error_cleanup; + } + } + +error_cleanup: + if ( outwbuffer != NULL ) + _freea(outwbuffer); + + _freea(inwbuffer); + + return retval; +} + +extern "C" int __cdecl __crtLCMapStringA( + _locale_t plocinfo, + LPCWSTR LocaleName, + DWORD dwMapFlags, + LPCSTR lpSrcStr, + int cchSrc, + LPSTR lpDestStr, + int cchDest, + int code_page, + BOOL bError + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return __crtLCMapStringA_stat( + _loc_update.GetLocaleT(), + LocaleName, + dwMapFlags, + lpSrcStr, + cchSrc, + lpDestStr, + cchDest, + code_page, + bError + ); +} diff --git a/test_data/lots_of_files/a_str.c b/test_data/lots_of_files/a_str.c new file mode 100644 index 0000000..272d38c --- /dev/null +++ b/test_data/lots_of_files/a_str.c @@ -0,0 +1,141 @@ +/*** +*a_str.c - A version of GetStringType. +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Use either GetStringTypeA or GetStringTypeW depending on which is +* unstubbed. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <stdlib.h> +#include <locale.h> +#include <awint.h> +#include <dbgint.h> +#include <malloc.h> +#include <awint.h> +#include <mtdll.h> +#include <setlocal.h> + +/*** +*int __cdecl __crtGetStringTypeA - Get type information about an ANSI string. +* +*Purpose: +* Internal support function. Assumes info in ANSI string format. Tries +* to use NLS API call GetStringTypeA if available and uses GetStringTypeW +* if it must. If neither are available it fails and returns FALSE. +* +*Entry: +* DWORD dwInfoType - see NT\Chicago docs +* LPCSTR lpSrcStr - char (byte) string for which character types +* are requested +* int cchSrc - char (byte) count of lpSrcStr (including NULL +* if any) +* LPWORD lpCharType - word array to receive character type information +* (must be twice the size of lpSrcStr) +* int code_page - for MB/WC conversion. If 0, use __lc_codepage +* BOOL bError - TRUE if MB_ERR_INVALID_CHARS set on call to +* MultiByteToWideChar when GetStringTypeW used. +* +*Exit: +* Success: TRUE +* Failure: FALSE +* +*Exceptions: +* +*******************************************************************************/ + +static BOOL __cdecl __crtGetStringTypeA_stat( + _locale_t plocinfo, + DWORD dwInfoType, + LPCSTR lpSrcStr, + int cchSrc, + LPWORD lpCharType, + int code_page, + BOOL bError + ) +{ + int retval1; + int buff_size; + wchar_t *wbuffer; + BOOL retval2 = FALSE; + + /* + * Convert string and return the requested information. Note that + * we are converting to a wide character string so there is not a + * one-to-one correspondence between number of multibyte chars in the + * input string and the number of wide chars in the buffer. However, + * there had *better be* a one-to-one correspondence between the + * number of multibyte characters and the number of WORDs in the + * return buffer. + */ + + /* + * Use __lc_codepage for conversion if code_page not specified + */ + + if (0 == code_page) + code_page = plocinfo->locinfo->lc_codepage; + + /* find out how big a buffer we need */ + if ( 0 == (buff_size = MultiByteToWideChar( code_page, + bError ? + MB_PRECOMPOSED | + MB_ERR_INVALID_CHARS + : MB_PRECOMPOSED, + lpSrcStr, + cchSrc, + NULL, + 0 )) ) + return FALSE; + + /* allocate enough space for wide chars */ + wbuffer = (wchar_t *)_calloca( sizeof(wchar_t), buff_size ); + if ( wbuffer == NULL ) { + return FALSE; + } + (void)memset( wbuffer, 0, sizeof(wchar_t) * buff_size ); + + /* do the conversion */ + if ( 0 != (retval1 = MultiByteToWideChar( code_page, + MB_PRECOMPOSED, + lpSrcStr, + cchSrc, + wbuffer, + buff_size )) ) + /* obtain result */ + retval2 = GetStringTypeW( dwInfoType, + wbuffer, + retval1, + lpCharType ); + + _freea(wbuffer); + + return retval2; +} + +extern "C" BOOL __cdecl __crtGetStringTypeA( + _locale_t plocinfo, + DWORD dwInfoType, + LPCSTR lpSrcStr, + int cchSrc, + LPWORD lpCharType, + int code_page, + BOOL bError + ) +{ + _LocaleUpdate _loc_update(plocinfo); + + return __crtGetStringTypeA_stat( + _loc_update.GetLocaleT(), + dwInfoType, + lpSrcStr, + cchSrc, + lpCharType, + code_page, + bError + ); +} diff --git a/test_data/lots_of_files/abort.c b/test_data/lots_of_files/abort.c new file mode 100644 index 0000000..7f4dcc1 --- /dev/null +++ b/test_data/lots_of_files/abort.c @@ -0,0 +1,125 @@ +/*** +*abort.c - abort a program by raising SIGABRT +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines abort() - print a message and raise SIGABRT. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdlib.h> +#include <internal.h> +#include <awint.h> +#include <rterr.h> +#include <signal.h> +#include <oscalls.h> +#include <mtdll.h> +#include <dbgint.h> + +#ifdef _DEBUG +#define _INIT_ABORT_BEHAVIOR _WRITE_ABORT_MSG +#else /* _DEBUG */ +#define _INIT_ABORT_BEHAVIOR _CALL_REPORTFAULT +#endif /* _DEBUG */ + +unsigned int __abort_behavior = _INIT_ABORT_BEHAVIOR; + +/*** +*void abort() - abort the current program by raising SIGABRT +* +*Purpose: +* print out an abort message and raise the SIGABRT signal. If the user +* hasn't defined an abort handler routine, terminate the program +* with exit status of 3 without cleaning up. +* +* Multi-thread version does not raise SIGABRT -- this isn't supported +* under multi-thread. +* +*Entry: +* None. +* +*Exit: +* Does not return. +* +*Uses: +* +*Exceptions: +* +*******************************************************************************/ + +void __cdecl abort ( + void + ) +{ + _PHNDLR sigabrt_act = SIG_DFL; + +#ifdef _DEBUG + if (__abort_behavior & _WRITE_ABORT_MSG) + { + /* write the abort message */ + _NMSG_WRITE(_RT_ABORT); + } +#endif /* _DEBUG */ + + + /* Check if the user installed a handler for SIGABRT. + * We need to read the user handler atomically in the case + * another thread is aborting while we change the signal + * handler. + */ + sigabrt_act = __get_sigabrt(); + if (sigabrt_act != SIG_DFL) + { + raise(SIGABRT); + } + + /* If there is no user handler for SIGABRT or if the user + * handler returns, then exit from the program anyway + */ + + if (__abort_behavior & _CALL_REPORTFAULT) + { +#if defined (_M_ARM) || defined (_CRT_APP) + __fastfail(FAST_FAIL_FATAL_APP_EXIT); +#else /* defined (_M_ARM) || defined (_CRT_APP) */ + if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE)) + __fastfail(FAST_FAIL_FATAL_APP_EXIT); + + _call_reportfault(_CRT_DEBUGGER_ABORT, STATUS_FATAL_APP_EXIT, EXCEPTION_NONCONTINUABLE); +#endif /* defined (_M_ARM) || defined (_CRT_APP) */ + } + + + /* If we don't want to call ReportFault, then we call _exit(3), which is the + * same as invoking the default handler for SIGABRT + */ + + + _exit(3); +} + +/*** +*unsigned int _set_abort_behavior(unsigned int, unsigned int) - set the behavior on abort +* +*Purpose: +* +*Entry: +* unsigned int flags - the flags we want to set +* unsigned int mask - mask the flag values +* +*Exit: +* Return the old behavior flags +* +*Exceptions: +* None +* +*******************************************************************************/ + +unsigned int __cdecl _set_abort_behavior(unsigned int flags, unsigned int mask) +{ + unsigned int oldflags = __abort_behavior; + __abort_behavior = oldflags & (~mask) | flags & mask; + return oldflags; +} diff --git a/test_data/lots_of_files/abs.c b/test_data/lots_of_files/abs.c new file mode 100644 index 0000000..c777b07 --- /dev/null +++ b/test_data/lots_of_files/abs.c @@ -0,0 +1,44 @@ +/*** +*abs.c - find absolute value +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines abs() - find the absolute value of an int. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <stdlib.h> + +#pragma function(abs, _abs64) + +/*** +*int abs(number) - find absolute value of number +* +*Purpose: +* Returns the absolute value of number (if number >= 0, returns number, +* else returns -number). +* +*Entry: +* int number - number to find absolute value of +* +*Exit: +* returns the aboslute value of number +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl abs ( + int number + ) +{ + return( number>=0 ? number : -number ); +} +__int64 __cdecl _abs64( + __int64 num + ) +{ + return (num >=0 ? num : -num); +} diff --git a/test_data/lots_of_files/access.c b/test_data/lots_of_files/access.c new file mode 100644 index 0000000..cfc0389 --- /dev/null +++ b/test_data/lots_of_files/access.c @@ -0,0 +1,135 @@ +/*** +*access.c - access function +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file has the _access() function which checks on file accessability. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <io.h> +#include <oscalls.h> +#include <stdlib.h> +#include <errno.h> +#include <msdos.h> +#include <internal.h> +#include <tchar.h> +#include <malloc.h> +#include <dbgint.h> + +/*** +*int _access(path, amode) - check whether file can be accessed under mode +* +*Purpose: +* Checks to see if the specified file exists and can be accessed +* in the given mode. +* +*Entry: +* _TSCHAR *path - pathname +* int amode - access mode +* (0 = exist only, 2 = write, 4 = read, 6 = read/write) +* +*Exit: +* returns 0 if file has given mode +* returns -1 and sets errno if file does not have given mode or +* does not exist +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _taccess ( + const _TSCHAR *path, + int amode + ) +{ + errno_t e; + e = _taccess_s(path,amode); + + return e ? -1 : 0 ; +} + +/*** +*errno_t _access_s(path, amode) - check whether file can be accessed under mode +* +*Purpose: +* Checks to see if the specified file exists and can be accessed +* in the given mode. +* +*Entry: +* _TSCHAR *path - pathname +* int amode - access mode +* (0 = exist only, 2 = write, 4 = read, 6 = read/write) +* +*Exit: +* returns 0 if file has given mode +* returns errno_t for any other errors +* +*Exceptions: +* +*******************************************************************************/ +#ifndef _UNICODE + +errno_t __cdecl _access_s ( + const char *path, + int amode + ) +{ + wchar_t* pathw = NULL; + errno_t retval; + + if (path) + { + if (!__copy_path_to_wide_string(path, &pathw)) + return errno; + } + + /* call the wide-char variant */ + retval = _waccess_s(pathw, amode); + + _free_crt(pathw); /* _free_crt leaves errno alone if everything completes as expected */ + + return retval; +} + +#else /* _UNICODE */ + +errno_t __cdecl _waccess_s ( + const wchar_t *path, + int amode + ) +{ + + WIN32_FILE_ATTRIBUTE_DATA attr_data; + + _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE( (path != NULL), EINVAL); + _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE( ((amode & (~6)) == 0), EINVAL); + + if (!GetFileAttributesExW(path, GetFileExInfoStandard, (void*) &attr_data)) { + /* error occured -- map error code and return */ + _dosmaperr(GetLastError()); + return errno; + } + + if(attr_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + /* All directories have read & write access */ + return 0; + } + + /* no error; see if returned premission settings OK */ + if ( (attr_data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && (amode & 2) ) { + /* no write permission on file, return error */ + _doserrno = E_access; + errno = EACCES; + return errno; + } + else + /* file exists and has requested permission setting */ + return 0; + +} + +#endif /* _UNICODE */ diff --git a/test_data/lots_of_files/agents.h b/test_data/lots_of_files/agents.h new file mode 100644 index 0000000..2ca59df --- /dev/null +++ b/test_data/lots_of_files/agents.h @@ -0,0 +1,13456 @@ +/*** +* ==++== +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* ==--== +* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +* +* agents.h +* +* Main public header file for ConcRT's asynchronous agents layer. This is the only header file a +* C++ program must include to use asynchronous agents. +* +* The core runtime, Parallel Patterns Library (PPL), and resource manager are defined in separate header files. +* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +****/ + +#pragma once + +#include <crtdefs.h> +#include <concrt.h> +#include <stdexcept> +#include <functional> +#include <tuple> +#include <type_traits> +#include <vector> +#include <concurrent_queue.h> + +#define _AGENTS_H + +#pragma pack(push,_CRT_PACKING) +#pragma warning(push) +#pragma warning(disable: 4100) // Unreferenced formal parameter - needed for document generation +#pragma warning(disable: 4702) // Unreachable code - needed for retail version code path +// Forward declarations + +/// <summary> +/// The <c>Concurrency</c> namespace provides classes and functions that provide access to the Concurrency Runtime, +/// a concurrent programming framework for C++. For more information, see <see cref="Concurrency Runtime"/>. +/// </summary> +/**/ +namespace Concurrency +{ +/// <summary> +/// Each message instance has an identity that follows it as it is +/// cloned and passed between messaging components. This cannot be the +/// address of the message object. +/// </summary> +/**/ +typedef __int32 runtime_object_identity; + +/// <summary> +/// A lock holder that acquires a non-reentrant lock on instantiation and releases +/// it on destruction. +/// </summary> +/**/ +typedef ::Concurrency::details::_NonReentrantPPLLock::_Scoped_lock _NR_lock; + +/// <summary> +/// A lock holder that acquires a reentrant lock on instantiation and releases +/// it on destruction +/// </summary> +/**/ +typedef ::Concurrency::details::_ReentrantPPLLock::_Scoped_lock _R_lock; + + +//*************************************************************************** +// Internal namespace: +// +// Concurrency::details contains definitions to support routines in the public namespaces and macros. +// Clients should not directly interact with this namespace. +//*************************************************************************** + +namespace details +{ + //************************************************************************** + // Core Messaging Support: + //************************************************************************** + + // + // A base class to derive from that keeps unique IDs on its derived classes + // + class _Runtime_object : public _AllocBase + { + public: + // Creates a new runtime object. + _CRTIMP2 _Runtime_object(); + + // Creates a runtime object from an identity. + _CRTIMP2 _Runtime_object(::Concurrency::runtime_object_identity _Id); + + // Gets the runtime object identity. + virtual ::Concurrency::runtime_object_identity _GetId() const + { + return _M_id; + } + + protected: + // The runtime object identity. + ::Concurrency::runtime_object_identity _M_id; + }; + + // A queue used to hold the messages for the messaging blocks + template<class _Message> + class _Queue : public _AllocBase + { + protected: + // A pointer to the head of the queue. + _Message * _M_pHead; + + // A pointer to a pointer to the tail of the queue. + _Message ** _M_ppTail; + + // The number of elements presently stored in the queue. + size_t _M_count; + + public: + typedef typename _Message type; + + // Create a Queue + _Queue() : _M_pHead(NULL), _M_ppTail(&_M_pHead), _M_count(0) + { + } + + // Destroy the queue + ~_Queue() + { + } + + // Returns the count of items in the queue + size_t _Count() const + { + return _M_count; + } + + // Add an item to the tail of the queue + // + // Returns a Boolean indicating whether the operation succeeded. + bool _Enqueue(_Message *_Element) + { + _CONCRT_ASSERT(_Element->_M_pNext == NULL); + _CONCRT_ASSERT(*_M_ppTail == NULL); + + *_M_ppTail = _Element; + _Element->_M_pNext = NULL; + _M_ppTail = &(_Element->_M_pNext); + _M_count++; + + return true; + } + + // Remove the specified element from the queue + // + // Returns a Boolean indicating whether the operation succeeded, that is, the message was found in the queue. + bool _Remove(_Message * _OldElement) + { + bool _Result = false; + + _CONCRT_ASSERT(_OldElement != NULL); + + if (_M_pHead == _OldElement) + { + _M_pHead = _OldElement->_M_pNext; + if (_M_pHead == NULL) + { + _M_ppTail = &_M_pHead; + } + + _OldElement->_M_pNext = NULL; + _M_count--; + _Result = true; + } + else + { + _Message * _Next = NULL; + for (_Message * _Node = _M_pHead; _Node != NULL; _Node = _Next) + { + _Next = _Node->_M_pNext; + + if (_Node->_M_pNext == _OldElement) + { + _Node->_M_pNext = _OldElement->_M_pNext; + // if this is the last element of the _Queue + if (_Node->_M_pNext == NULL && _M_count == 1) + { + _M_ppTail = &_M_pHead; + } + + _OldElement->_M_pNext = NULL; + _M_count--; + _Result = true; + break; + } + } + } + + return _Result; + } + + // Dequeue an item from the head of queue + // + // Returns a pointer to the message found at the head of the queue. + _Message * _Dequeue() + { + if (_M_pHead == NULL) + { + return NULL; + } + + _Message * _Result = _M_pHead; + + _M_pHead = _Result->_M_pNext; + if (_M_pHead == NULL) + { + _M_ppTail = &_M_pHead; + } + + _Result->_M_pNext = NULL; + _M_count--; + return _Result; + } + + // Return the item at the head of the queue, without dequeuing + // + // Returns a pointer to the message found at the head of the queue. + _Message * _Peek() + { + return _M_pHead; + } + + // Return true if the ID matches the message at the head of the queue + bool _Is_head(runtime_object_identity _MsgId) + { + // Peek at the next message in the message buffer. Use it to + // check if the IDs match + _Message * _Msg = _M_pHead; + + if (_Msg == NULL || _Msg->msg_id() != _MsgId) + { + return false; + } + + return true; + } + }; + + // + // _Dynamic_array implements a container very similar to std::vector. + // However, it exposes a reduced subset of functionality that is + // geared towards use in network_link_registry. The array acess is not + // thread-safe. + // + template<class _Type> + class _Dynamic_array + { + public: + + typedef _Dynamic_array<_Type> _Myt; + + typedef _Type& reference; + typedef _Type const& const_reference; + + // + // Construct a dynamic array + // + _Dynamic_array() + { + _Init(); + } + + // + // Release any resources used by dynamic array + // + ~_Dynamic_array() + { + _Clear(); + } + + // + // Assignment operator. Copy the contents of _Right + // + _Myt& operator=(const _Myt& _Right) + { + if (this != &_Right) + { + // Remove all the elements + _Clear(); + + // Allocate space for the new elements + size_t _Size = _Right._Size(); + _Grow(_Size); + + // Copy over the new elements + for (size_t _I=0; _I < _Size; _I++) + { + _Push_back(_Right[_I]); + } + } + + return *this; + } + + // + // Clear all the elements in the array + // + void _Clear() + { + if (_M_array != NULL) + { + delete [] _M_array; + _Init(); + } + } + + // + // Add an element to the end of the array + // + void _Push_back(_Type const& _Element) + { + if (_M_index >= _M_size) + { + // Not enough space. Grow the array + size_t _NewSize = (_M_index + 1) * _S_growthFactor; + _Grow(_NewSize); + } + + _CONCRT_ASSERT(_M_index < _M_size); + _M_array[_M_index] = _Element; + _M_index++; + } + + // + // Index operation. Retrieve an element at the specified index. No bounds check is done. + // + reference operator[](size_t _Pos) + { + _CONCRT_ASSERT(_Pos < _M_size); + return _M_array[_Pos]; + } + + // + // Index operation. Retrieve an element at the specified index. No bounds check is done. + // + const_reference operator[](size_t _Pos) const + { + _CONCRT_ASSERT(_Pos < _M_size); + return _M_array[_Pos]; + } + + // + // Returns the count of elements in the array + // + size_t _Size() const + { + return _M_index; + } + + // + // Swap the contents of this array with _Right + // + void _Swap(_Myt& _Right) + { + if (this != &_Right) + { + // Swap the details. + _Type * _Array = _M_array; + size_t _Index = _M_index; + size_t _Size = _M_size; + + _M_array = _Right._M_array; + _M_index = _Right._M_index; + _M_size = _Right._M_size; + + _Right._M_array = _Array; + _Right._M_index = _Index; + _Right._M_size = _Size; + } + } + + private: + // + // Initialize the array + // + void _Init() + { + _M_array = NULL; + _M_index = 0; + _M_size = 0; + } + + // + // Grow the array to the given size. The old elements are copied over. + // + void _Grow(size_t _NewSize) + { + _CONCRT_ASSERT( _NewSize > _M_size ); + + _Type * _Array = new _Type[_NewSize]; + + if (_M_array != NULL) + { + // Copy over the elememts + for (size_t _I = 0; _I < _M_size; _I++) + { + _Array[_I] = _M_array[_I]; + } + + delete [] _M_array; + } + + _M_array = _Array; + _M_size = _NewSize; + } + + // Private data members + + // Array of elements + _Type * _M_array; + + // Index where the next element should be inserted + size_t _M_index; + + // Capacity of the array. + size_t _M_size; + + static const int _S_growthFactor = 2; + }; + + // + // Returns an identifier for the given object that could be used + // in an ETW trace (call to _Trace_agents) + // + template <class _Type> + __int64 _Trace_agents_get_id(_Type * _PObject) + { + return reinterpret_cast<__int64>(_PObject); + } + +} // namespace details + +//************************************************************************** +// Public Namespace: +// +// Anything in the Concurrency namespace is intended for direct client consumption. +// +//************************************************************************** + +// +// Forward declarations: +// +template<class _Type> class ISource; +template<class _Type> class ITarget; + +//************************************************************************** +// Network link registry +//************************************************************************** + +// Forward declaration for use in the iterator +template<class _Block> class network_link_registry; + +/// <summary> +/// Const iterator for network link registry. Message blocks should use +/// the link_registry::iterator type for iteration. +/// </summary> +/// <typeparam name="_Block"> +/// The network block type +/// </typeparam> +/**/ +template<class _Block> +class _Network_link_iterator +{ +public: + + typedef _Network_link_iterator<_Block> _Myt; + typedef network_link_registry<_Block> _MyContainer; + + // Element type + typedef _Block* _EType; + + // Const iterator - iterator shall not be used to modify the links + typedef _EType const& const_reference; + typedef _EType const* const_pointer; + + /// <summary> + /// Construct iterator + /// </summary> + /**/ + _Network_link_iterator(_MyContainer * _PNetwork_link, size_t _Index) : _M_pNetwork_link(_PNetwork_link), _M_index(_Index), _M_value(NULL) + { + _M_pNetwork_link->_Next_index(_M_index); + } + + /// <summary> + /// Copy construct an iterator + /// </summary> + /**/ + _Network_link_iterator(_Myt const& _Right) + { + _M_pNetwork_link = _Right._M_pNetwork_link; + _M_index = _Right._M_index; + } + + /// <summary> + /// Copy assign an iterator + /// </summary> + /**/ + _Myt const& operator=(_Myt const& _Right) + { + _M_pNetwork_link = _Right._M_pNetwork_link; + _M_index = _Right._M_index; + return *this; + } + + /// <summary> + /// Returns the object pointed to by the iterator + /// </summary> + /// <returns> + /// Reference to the object pointed to by the iterator + /// </returns> + /**/ + const_reference operator*() + { + _M_value = _M_pNetwork_link->_Get_element(_M_index); + return _M_value; + } + + /// <summary> + /// Returns a pointer to the class object + /// </summary> + /// <returns> + /// Returns a pointer to the class object + /// </returns> + /**/ + const_pointer operator->() const + { + return (&**this); + } + + /// <summary> + /// Pre-increment the iterator to point to the next element + /// </summary> + /// <returns> + /// Reference to the object pointer to by the iterator after + /// incrementing it + /// </returns> + /**/ + _Myt& operator++() + { + ++_M_index; + _M_pNetwork_link->_Next_index(_M_index); + return (*this); + } + + /// <summary> + /// Post-increment the iterator to point to the next element + /// </summary> + /// <returns> + /// Reference to the object pointer to by the iterator before + /// incrementing it + /// </returns> + /**/ + _Myt operator++(int) + { + _Myt _Tmp = *this; + ++*this; + return (_Tmp); + } + +private: + + // Pointer to the underlying container (network link registry) + _MyContainer * _M_pNetwork_link; + + // Current index + size_t _M_index; + + // Current value + _EType _M_value; +}; + +/// <summary> +/// The <c>network_link_registry</c> abstract base class manages the links between source +/// and target blocks. +/// </summary> +/// <typeparam name="_Block"> +/// The block data type being stored in the <c>network_link_registry</c>. +/// </typeparam> +/// <remarks> +/// The <c>network link registry</c> is not safe for concurrent access. +/// </remarks> +/// <seealso cref="single_link_registry Class"/> +/// <seealso cref="multi_link_registry Class"/> +/**/ +template<class _Block> +class network_link_registry +{ +public: + + /// <summary> + /// A type that represents the block type stored in the <c>network_link_registry</c> object. + /// </summary> + /**/ + typedef typename _Block type; + + /// <summary> + /// A type that represents an element pointer stored in the <c>network_link_registry</c> object. + /// </summary> + /**/ + typedef _Block * _EType; + + /// <summary> + /// A type that provides a reference to a <c>const</c> element stored in a + /// <c>network_link_registry</c> object for reading and performing const operations. + /// </summary> + /**/ + typedef _EType const& const_reference; + + /// <summary> + /// A type that provides a pointer to a <c>const</c> element in a + /// <c>network_link_registry</c> object. + /// </summary> + /**/ + typedef _EType const* const_pointer; + + // Make the iterators friends so that they can access some of the + // private routines such as _Get_element. + /**/ + friend class _Network_link_iterator<_Block>; + + /// <summary> + /// A type that provides an iterator that can read or modify any element in a + /// <c>network_link_registry</c> object. + /// </summary> + /**/ + typedef _Network_link_iterator<_Block> iterator; + + /// <summary> + /// When overridden in a derived class, adds a link to the <c>network_link_registry</c> + /// object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be added. + /// </param> + /**/ + virtual void add(_EType _Link) = 0; + + /// <summary> + /// When overridden in a derived class, removes a specified block from the + /// <c>network_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be removed, if found. + /// </param> + /// <returns> + /// <c>true</c> if the link was found and removed, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool remove(_EType _Link) = 0; + + /// <summary> + /// When overridden in a derived class, searches the <c>network_link_registry</c> object + /// for a specified block. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block that is being searched for in the <c>network_link_registry</c> + /// object. + /// </param> + /// <returns> + /// <c>true</c> if the block was found, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool contains(_EType _Link) = 0; + + /// <summary> + /// When overridden in a derived class, returns the number of items in the + /// <c>network_link_registry</c> object. + /// </summary> + /// <returns> + /// The number of items in the <c>network_link_registry</c> object. + /// </returns> + /**/ + virtual size_t count() = 0; + + /// <summary> + /// When overridden in a derived class, returns an iterator to the first element in the + /// <c>network_link_registry</c> object. + /// </summary> + /// <remarks> + /// The end state of the iterator is indicated by a <c>NULL</c> link. + /// </remarks> + /// <returns> + /// An iterator addressing the first element in the <c>network_link_registry</c> object. + /// </returns> + /**/ + virtual iterator begin() = 0; + +protected: + + /// <summary> + /// Skips empty slots and updates the index to the next + /// non-empty slot. This is called by the iterator. + /// </summary> + /// <param name="_Index"> + /// A reference to the index that is to be updated. + /// </param> + /**/ + virtual void _Next_index(size_t& _Index) = 0; + + /// <summary> + /// Retrieves the element at the given index. If the index is out of bounds, + /// <c>NULL</c> is returned. Users need to use the iterator to access the links. + /// </summary> + /// <param name="_Index"> + /// Index of the link to be retrieved. + /// </param> + /// <returns> + /// The element in the registry at the index specified by the <paramref name="_Index"/> parameter. + /// </returns> + /**/ + virtual _EType _Get_element(size_t _Index) const = 0; +}; + +/// <summary> +/// The <c>single_link_registry</c> object is a <c>network_link_registry</c> that manages +/// only a single source or target block. +/// </summary> +/// <typeparam name="_Block"> +/// The block data type being stored in the <c>single_link_registry</c> object. +/// </typeparam> +/// <seealso cref="multi_link_registry Class"/> +/**/ +template<class _Block> +class single_link_registry : public network_link_registry<_Block> +{ +public: + + /// <summary> + /// Constructs a <c>single_link_registry</c> object. + /// </summary> + /**/ + single_link_registry() : _M_connectedLink(NULL) + { + } + + /// <summary> + /// Destroys the <c>single_link_registry</c> object. + /// </summary> + /// <remarks> + /// The method throws an <see cref="invalid_operation Class">invalid_operation</see> exception if + /// it is called before the link is removed. + /// </remarks> + /**/ + virtual ~single_link_registry() + { + // It is an error to delete link registry with links + // still present + if (count() != 0) + { + throw invalid_operation("Deleting link registry before removing all the links"); + } + } + + /// <summary> + /// Adds a link to the <c>single_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be added. + /// </param> + /// <remarks> + /// The method throws an <see cref="invalid_link_target Class">invalid_link_target</see> exception + /// if there is already a link in this registry. + /// </remarks> + /**/ + virtual void add(_EType _Link) + { + if (_Link == NULL) + { + return; + } + + // Only one link can be added. + if (_M_connectedLink != NULL) + { + throw invalid_link_target("_Link"); + } + + _M_connectedLink = _Link; + } + + /// <summary> + /// Removes a link from the <c>single_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be removed, if found. + /// </param> + /// <returns> + /// <c>true</c> if the link was found and removed, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool remove(_EType _Link) + { + if ((_Link != NULL) && (_M_connectedLink == _Link)) + { + _M_connectedLink = NULL; + return true; + } + + return false; + } + + /// <summary> + /// Searches the <c>single_link_registry</c> object for a specified block. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block that is to be searched for in the <c>single_link_registry</c> object. + /// </param> + /// <returns> + /// <c>true</c> if the link was found, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool contains(_EType _Link) + { + return ((_Link != NULL) && (_M_connectedLink == _Link)); + } + + /// <summary> + /// Counts the number of items in the <c>single_link_registry</c> object. + /// </summary> + /// <returns> + /// The number of items in the <c>single_link_registry</c> object. + /// </returns> + /**/ + virtual size_t count() + { + return (_M_connectedLink == NULL) ? 0 : 1; + } + + /// <summary> + /// Returns an iterator to the first element in the <c>single_link_registry</c> object. + /// </summary> + /// <remarks> + /// The end state is indicated by a <c>NULL</c> link. + /// </remarks> + /// <returns> + /// An iterator addressing the first element in the <c>single_link_registry</c> object. + /// </returns> + /**/ + virtual iterator begin() + { + return (iterator(this, 0)); + } + +protected: + + /// <summary> + /// Skips empty slots and updates the index to the next + /// non-empty slot. This is called by the iterator. + /// </summary> + /// <param name="_Index"> + /// A reference to the index that is to be updated. + /// </param> + /**/ + virtual void _Next_index(size_t& _Index) + { + if (_M_connectedLink == NULL) + { + _Index++; + } + } + + /// <summary> + /// Retrieves the element at the given index. If the index is out of bounds, + /// <c>NULL</c> is returned. Users need to use the iterator to access the links. + /// </summary> + /// <param name="_Index"> + /// The index of the link to be retrieved. + /// </param> + /// <returns> + /// The element in the registry at the index specified by the <paramref name="_Index"/> parameter. + /// </returns> + /**/ + virtual _EType _Get_element(size_t _Index) const + { + if (_Index == 0) + { + return _M_connectedLink; + } + + return NULL; + } + +private: + + // A single pointer is used to hold the link + _EType _M_connectedLink; +}; + +/// <summary> +/// The <c>multi_link_registry</c> object is a <c>network_link_registry</c> that manages multiple +/// source blocks or multiple target blocks. +/// </summary> +/// <typeparam name="_Block"> +/// The block data type being stored in the <c>multi_link_registry</c> object. +/// </typeparam> +/// <seealso cref="single_link_registry Class"/> +/**/ +template<class _Block> +class multi_link_registry : public network_link_registry<_Block> +{ +public: + + /// <summary> + /// Constructs a <c>multi_link_registry</c> object. + /// </summary> + /**/ + multi_link_registry() : _M_maxLinks(_NOT_SET) + { + } + + /// <summary> + /// Destroys the <c>multi_link_registry</c> object. + /// </summary> + /// <remarks> + /// The method throws an <see cref="invalid_operation Class">invalid_operation</see> exception if + /// called before all links are removed. + /// </remarks> + /**/ + virtual ~multi_link_registry() + { + // It is an error to delete link registry with links + // still present + if (count() != 0) + { + throw invalid_operation("Deleting link registry before removing all the links"); + } + } + + /// <summary> + /// Sets an upper bound on the number of links that the <c>multi_link_registry</c> object + /// can hold. + /// </summary> + /// <param name="_MaxLinks"> + /// The maximum number of links that the <c>multi_link_registry</c> object can hold. + /// </param> + /// <remarks> + /// After a bound is set, unlinking an entry will cause the <c>multi_link_registry</c> + /// object to enter an immutable state where further calls to <c>add</c> will throw an + /// <c>invalid_link_target</c> exception. + /// </remarks> + /**/ + void set_bound(size_t _MaxLinks) + { + _CONCRT_ASSERT(count() == 0); + _M_maxLinks = _MaxLinks; + } + + /// <summary> + /// Adds a link to the <c>multi_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be added. + /// </param> + /// <remarks> + /// The method throws an <see cref="invalid_link_target Class">invalid_link_target</see> exception if + /// the link is already present in the registry, or if a bound has already been set with the <c>set_bound</c> + /// function and a link has since been removed. + /// </remarks> + /**/ + virtual void add(_EType _Link) + { + if (_Link == NULL) + { + return; + } + + _Add(_Link); + } + + /// <summary> + /// Removes a link from the <c>multi_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be removed, if found. + /// </param> + /// <returns> + /// <c>true</c> if the link was found and removed, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool remove(_EType _Link) + { + if (_Link == NULL) + { + return false; + } + + return (_Remove(_Link)); + } + + /// <summary> + /// Searches the <c>multi_link_registry</c> object for a specified block. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block that is to be searched for in the <c>multi_link_registry</c> object. + /// </param> + /// <returns> + /// <c>true</c> if the specified block was found, <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool contains(_EType _Link) + { + if (_Link == NULL) + { + return false; + } + + return (_Find(_Link) < _M_vector._Size()); + } + + /// <summary> + /// Counts the number of items in the <c>multi_link_registry</c> object. + /// </summary> + /// <returns> + /// The number of items in the <c>multi_link_registry</c> object. + /// </returns> + /**/ + virtual size_t count() + { + return _Count(); + } + + /// <summary> + /// Returns an iterator to the first element in the <c>multi_link_registry</c> object. + /// </summary> + /// <remarks> + /// The end state is indicated by a <c>NULL</c> link. + /// </remarks> + /// <returns> + /// An iterator addressing the first element in the <c>multi_link_registry</c> object. + /// </returns> + /**/ + virtual iterator begin() + { + return (iterator(this, 0)); + } + +protected: + + /// <summary> + /// Skips empty slots and updates the index to the next + /// non-empty slot. This is called by the iterator. + /// </summary> + /// <param name="_Index"> + /// A reference to the index that is to be updated. + /// </param> + /**/ + virtual void _Next_index(size_t& _Index) + { + size_t _Size = _M_vector._Size(); + while (_Index < _Size) + { + if (_M_vector[_Index] != NULL) + { + break; + } + + ++_Index; + } + } + + /// <summary> + /// Retrieves the element at the given index. If the index is out of bounds, + /// <c>NULL</c> is returned. Users need to use the iterator to access the links + /// </summary> + /// <param name="_Index"> + /// Index of the link to be retrieved. + /// </param> + /// <returns> + /// The element in the registry at the index specified by the <paramref name="_Index"/> parameter. + /// </returns> + /**/ + virtual _EType _Get_element(size_t _Index) const + { + if (_Index < _M_vector._Size()) + { + return _M_vector[_Index]; + } + + return NULL; + } + +private: + + /// <summary> + /// Adds a link to the <c>multi_link_registry</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be added. + /// </param> + /**/ + void _Add(_EType _Link) + { + size_t _Size = _M_vector._Size(); + size_t _Insert_pos = 0; + + _CONCRT_ASSERT(_Link != NULL); + + // If max links is set, ensure that inserting the new + // link will not exceed the bound. + if ((_M_maxLinks != _NOT_SET) && ((_Size+1) > (size_t) _M_maxLinks)) + { + throw invalid_link_target("_Link"); + } + + for (size_t _Index = 0; _Index < _Size; _Index++) + { + if (_M_vector[_Index] != NULL) + { + // We want to find the first NULL entry after all the + // non-NULL entries. + _Insert_pos = _Index + 1; + + // Throw if dupiclate entry is found + if (_M_vector[_Index] == _Link) + { + throw invalid_link_target("_Link"); + } + } + } + + if (_Insert_pos < _Size) + { + _M_vector[_Insert_pos] = _Link; + } + else + { + _M_vector._Push_back(_Link); + } + } + + /// <summary> + /// Removes a link from the <c>multi_link_registry</c> + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be removed, if found. + /// </param> + /// <returns> + /// <c>true</c> if the specified link was found and removed, <c>false</c> otherwise. + /// </returns> + /**/ + bool _Remove(_EType _Link) + { + _CONCRT_ASSERT(_Link != NULL); + + for (size_t _Index = 0; _Index < _M_vector._Size(); _Index++) + { + if (_M_vector[_Index] == _Link) + { + _M_vector[_Index] = NULL; + + // If max links is set, prevent new additions to the registry + if (_M_maxLinks != _NOT_SET && _M_maxLinks > 0) + { + // Setting the bound to 0. This causes add to always throw. + _M_maxLinks = 0; + } + + return true; + } + } + + return false; + } + + + /// <summary> + /// Searches the registry for the given link + /// </summary> + /// <param name="_Link"> + /// A pointer to a block that is to be searched. + /// </param> + /// <returns> + /// Index of the entry if found. + /// </returns> + /**/ + virtual size_t _Find(_EType _Link) + { + size_t _Index = 0; + for (_Index = 0; _Index < _M_vector._Size(); _Index++) + { + if (_M_vector[_Index] == _Link) + { + break; + } + } + + return _Index; + } + + /// <summary> + /// Returns the count of items in the registry. + /// </summary> + /// <returns> + /// The count of items in the registry. + /// </returns> + /**/ + size_t _Count() const + { + size_t _Count = 0; + + for (size_t _Index = 0; _Index < _M_vector._Size(); _Index++) + { + if (_M_vector[_Index] != NULL) + { + _Count++; + } + } + + return _Count; + } + + static const size_t _NOT_SET = SIZE_MAX; + + // Maximum number of links allowed. + size_t _M_maxLinks; + + // ::Concurrency::details::_Dynamic_array is used to hold the links + ::Concurrency::details::_Dynamic_array<_EType> _M_vector; +}; + +// Forward declaration for the iterator +template<class _LinkRegistry> class source_link_manager; + +/// <summary> +/// Const Iterator for referenced link manager. +/// </summary> +/// <typeparam name="_LinkRegistry"> +/// The underlying network link registry +/// </typeparam> +/**/ +template<class _LinkRegistry> +class _Source_link_iterator +{ +public: + + typedef typename _LinkRegistry::type _Block; + + typedef _Source_link_iterator<_LinkRegistry> _Myt; + typedef source_link_manager<_LinkRegistry> _MyContainer; + + // Element type + typedef _Block* _EType; + + // Const iterator - iterator shall not be used to modify the links + typedef _EType const& const_reference; + typedef _EType const* const_pointer; + + /// <summary> + /// Construct iterator + /// </summary> + /**/ + _Source_link_iterator(_MyContainer * _PNetwork_link, size_t _Index) : _M_pNetwork_link(_PNetwork_link), _M_index(_Index), _M_sentinel(NULL) + { + // Take a snapshot of the link registry. This will reference the registry. + _M_pNetwork_link->_To_array(_M_array); + } + + /// <summary> + /// Destruct iterator + /// </summary> + /**/ + virtual ~_Source_link_iterator() + { + if (_M_pNetwork_link != NULL) + { + _M_pNetwork_link->release(); + } + } + /// <summary> + /// Copy construct an iterator + /// </summary> + /**/ + _Source_link_iterator(_Myt const& _Right) + { + _M_pNetwork_link = _Right._M_pNetwork_link; + _M_index = _Right._M_index; + _M_array = _Right._M_array; + + _M_pNetwork_link->reference(); + } + + /// <summary> + /// Copy assign an iterator + /// </summary> + /**/ + _Myt const& operator=(_Myt const& _Right) + { + _MyContainer * _OldContainer = _M_pNetwork_link; + _CONCRT_ASSERT(_OldContainer != NULL); + + _M_pNetwork_link = _Right._M_pNetwork_link; + _M_index = _Right._M_index; + _M_array = _Right._M_array; + + if (_OldContainer != _M_pNetwork_link) + { + _OldContainer->release(); + _M_pNetwork_link->reference(); + } + + return *this; + } + + /// <summary> + /// Returns the object pointed to by the iterator + /// </summary> + /// <returns> + /// Reference to the object pointed to by the iterator + /// </returns> + /**/ + const_reference operator*() + { + return _Get(0); + } + + /// <summary> + /// Returns a pointer to the class object + /// </summary> + /// <returns> + /// Returns a pointer to the class object + /// </returns> + /**/ + const_pointer operator->() const + { + return (&**this); + } + + /// <summary> + /// Index operation. Retrieve an element at the specified index. + /// </summary> + /**/ + const_reference operator[](size_t _Pos) const + { + return _Get(_Pos); + } + + /// <summary> + /// Pre-increment the iterator to point to the next element + /// </summary> + /// <returns> + /// Reference to the object pointer to by the iterator after incrementing it + /// </returns> + /**/ + _Myt& operator++() + { + ++_M_index; + return (*this); + } + + /// <summary> + /// Post-increment the iterator to point to the next element + /// </summary> + /// <returns> + /// Reference to the object pointer to by the iterator before incrementing it + /// </returns> + /**/ + _Myt operator++(int) + { + _Myt _Tmp = *this; + ++*this; + return (_Tmp); + } + +private: + + // Get the element at the given offset. + const_reference _Get(size_t _Pos) const + { + size_t _Index = _M_index + _Pos; + if (_Index >= _M_array._Size()) + { + return _M_sentinel; + } + + return _M_array[_Index]; + } + + // Array to hold the snapshot of the link registry + ::Concurrency::details::_Dynamic_array<_EType> _M_array; + + // Pointer to the underlying container (network link registry) + _MyContainer * _M_pNetwork_link; + + // Current index + size_t _M_index; + + // Sentinel value to return on bounds overflow + _EType _M_sentinel; +}; + +/// <summary> +/// The <c>source_link_manager</c> object manages messaging block network links +/// to <c>ISource</c> blocks. +/// </summary> +/// <typeparam name="_LinkRegistry"> +/// The network link registry. +/// </typeparam> +/// <remarks> +/// Currently, the source blocks are reference counted. This is a wrapper on a +/// <c>network_link_registry</c> object that allows concurrent access to the links and +/// provides the ability to reference the links through callbacks. Message +/// blocks (<c>target_block</c>s or <c>propagator_block</c>s) should use this class +/// for their source links. +/// </remarks> +/// <seealso cref="single_link_registry Class"/> +/// <seealso cref="multi_link_registry Class"/> +/**/ +template<class _LinkRegistry> +class source_link_manager +{ +public: + + /// <summary> + /// The type of link registry being managed by the <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef _LinkRegistry type; + + /// <summary> + /// The type of the blocks being managed by the <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef typename _LinkRegistry::type _Block; + + /// <summary> + /// The method signature for a callback method for this <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef std::tr1::function<void(_Block *, bool)> _Callback_method; + + /// <summary> + /// A type that represents a pointer to an element stored in the <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef _Block * _EType; + + /// <summary> + /// A type that provides a reference to a <c>const</c> element stored in a <c>source_link_manager</c> object + /// for reading and performing const operations. + /// </summary> + /**/ + typedef _EType const& const_reference; + + /// <summary> + /// A type that provides a pointer to a <c>const</c> element in a <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef _EType const* const_pointer; + + // Iterator + friend class _Source_link_iterator<_LinkRegistry>; + + /// <summary> + /// A type that provides an iterator that can read or modify any element in the + /// <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef _Source_link_iterator<_LinkRegistry> iterator; + + /// <summary> + /// A type that provides a reentrant lock for the <c>source_link_manager</c> object. + /// </summary> + /**/ + typedef ::Concurrency::details::_ReentrantPPLLock _LockType; + + /// <summary> + /// A type that provides a RAII scoped lock holder for a lock. + /// </summary> + /**/ + typedef _LockType::_Scoped_lock _LockHolder; + + /// <summary> + /// Constructs a <c>source_link_manager</c> object. + /// </summary> + /**/ + source_link_manager() : _M_iteratorCount(0), _M_pLinkedTarget(NULL) + { + } + + /// <summary> + /// Destroys the <c>source_link_manager</c> object. + /// </summary> + /**/ + ~source_link_manager() + { + _CONCRT_ASSERT(_M_pendingRemove._Size() == 0); + } + + /// <summary> + /// Registers the target block that holds this <c>source_link_manager</c> object. + /// </summary> + /// <param name="_PTarget"> + /// The target block holding this <c>source_link_manager</c> object. + /// </param> + /**/ + void register_target_block(_Inout_ ITarget<typename _Block::source_type> * _PTarget) + { + _M_pLinkedTarget = _PTarget; + } + + /// <summary> + /// Sets the maximum number of source links that can be added to this + /// <c>source_link_manager</c> object. + /// </summary> + /// <param name="_MaxLinks"> + /// The maximum number of links. + /// </param> + /**/ + void set_bound(size_t _MaxLinks) + { + _M_links.set_bound(_MaxLinks); + } + + /// <summary> + /// Adds a source link to the <c>source_link_manager</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be added. + /// </param> + /**/ + void add(_EType _Link) + { + if (_Link == NULL) + { + return; + } + + { + _LockHolder _Lock(_M_lock); + _M_links.add(_Link); + + // We need to add the _Link first and then invoke the + // callback because _Add could throw. + + // As soon as the above lock is released, remove would + // find the link that was added and could unlink it before + // we are able to invoke the notification below. Keeping an + // active iterator would prevent that from happening. + _M_iteratorCount++; + } + + // Acquire a reference on this link by the target + _Link->acquire_ref(_M_pLinkedTarget); + + // Release the active iterator + release(); + } + + /// <summary> + /// Removes a link from the <c>source_link_manager</c> object. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block to be removed, if found. + /// </param> + /// <returns> + /// <c>true</c> if the link was found and removed, <c>false</c> otherwise. + /// </returns> + /**/ + bool remove(_EType _Link) + { + bool _Removed = false; + _EType _RemovedLink = NULL; + ITarget<typename _Block::source_type> * _LinkedTarget = _M_pLinkedTarget; + + if (_Link == NULL) + { + return false; + } + + { + _LockHolder _Lock(_M_lock); + _Removed = _M_links.remove(_Link); + + if (!_Removed) + { + // No change was made + return _Removed; + } + + if (_M_iteratorCount == 0) + { + // Set the removed link to indicate that + // notification callback needs to be invoked. + _RemovedLink = _Link; + } + else + { + // The iterator will complete the pending operation + _M_pendingRemove._Push_back(_Link); + } + } + + // NOTE: touching "this" pointer is dangerous as soon as the above lock is released + + // Release the reference for this link + if (_RemovedLink != NULL) + { + _RemovedLink->release_ref(_LinkedTarget); + } + + return _Removed; + } + + /// <summary> + /// Acquires a reference on the <c>source_link_manager</c> object. + /// </summary> + /**/ + void reference() + { + _LockHolder _Lock(_M_lock); + _M_iteratorCount++; + } + + /// <summary> + /// Releases the reference on the <c>source_link_manager</c> object. + /// </summary> + /**/ + void release() + { + ITarget<typename _Block::source_type> * _LinkedTarget = _M_pLinkedTarget; + ::Concurrency::details::_Dynamic_array<_EType> _LinksToRemove; + + { + _LockHolder _Lock(_M_lock); + _CONCRT_ASSERT(_M_iteratorCount > 0); + _M_iteratorCount--; + + if (_M_iteratorCount == 0) + { + if (_M_pendingRemove._Size() > 0) + { + // Snap the pending remove list with the lock held + _M_pendingRemove._Swap(_LinksToRemove); + } + } + } + + // NOTE: touching "this" pointer is dangerous as soon as the above lock is released + + // Release the references + size_t _Size = _LinksToRemove._Size(); + + for (size_t _I=0; _I < _Size; _I++) + { + _LinksToRemove[_I]->release_ref(_LinkedTarget); + } + } + + /// <summary> + /// Searches the <c>network_link_registry</c> within this <c>source_link_manager</c> + /// object for a specified block. + /// </summary> + /// <param name="_Link"> + /// A pointer to a block that is to be searched for in the <c>source_link_manager</c> object. + /// </param> + /// <returns> + /// <c>true</c> if the specified block was found, <c>false</c> otherwise. + /// </returns> + /**/ + bool contains(_EType _Link) + { + _LockHolder _Lock(_M_lock); + return _M_links.contains(_Link); + } + + /// <summary> + /// Counts the number of linked blocks in the <c>source_link_manager</c> object. + /// </summary> + /// <returns> + /// The number of linked blocks in the <c>source_link_manager</c> object. + /// </returns> + /**/ + size_t count() + { + _LockHolder _Lock(_M_lock); + return _M_links.count(); + } + + + /// <summary> + /// Returns an iterator to the first element in the <c>source_link_manager</c> object. + /// </summary> + /// <remarks> + /// The end state of the iterator is indicated by a <c>NULL</c> link. + /// </remarks> + /// <returns> + /// An iterator addressing the first element in the <c>source_link_manager</c> object. + /// </returns> + /**/ + iterator begin() + { + return (iterator(this, 0)); + } + +private: + + // Called by the iterator. This routine takes a snapshot of the links + // in the registry and copies it to the array provided. + void _To_array(::Concurrency::details::_Dynamic_array<_EType>& _Array) + { + _LockHolder _Lock(_M_lock); + _M_iteratorCount++; + + for(_LinkRegistry::iterator _Link = _M_links.begin(); *_Link != NULL; _Link++) + { + _Array._Push_back(*_Link); + } + } + + // Internal lock used for synchronization + _LockType _M_lock; + + // Count to indicate that an iterator is active + volatile long _M_iteratorCount; + + // A vector of all pending link remove operations + ::Concurrency::details::_Dynamic_array<_EType> _M_pendingRemove; + + // Underlying link registry + _LinkRegistry _M_links; + + // Target block holding this source link manager + ITarget<typename _Block::source_type> * volatile _M_pLinkedTarget; +}; + +/// <summary> +/// The valid responses for an offer of a <c>message</c> object to a block. +/// </summary> +/**/ +enum message_status +{ + /// <summary> + /// The target accepted the message. + /// </summary> + /**/ + accepted, + /// <summary> + /// The target did not accept the message. + /// </summary> + /**/ + declined, + /// <summary> + /// The target postponed the message. + /// </summary> + /**/ + postponed, + /// <summary> + /// The target tried to accept the message, but it was no longer available. + /// </summary> + /**/ + missed +}; + +/// <summary> +/// The basic message envelope containing the data payload being passed between +/// messaging blocks. +/// </summary> +/// <typeparam name="_Type"> +/// The data type of the payload within the message. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/**/ +template<class _Type> +class message : public ::Concurrency::details::_Runtime_object +{ + friend class ::Concurrency::details::_Queue<message<_Type>>; + +public: + /// <summary> + /// Constructs a <c>message</c> object. + /// </summary> + /// <param name="_P"> + /// The payload of this message. + /// </param> + /// <remarks> + /// The constructor that takes a pointer to a <c>message</c> object as an argument + /// throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if the parameter <paramref name="_Msg"/> is <c>NULL</c>. + /// </remarks> + /**/ + message(_Type const &_P) : payload(_P), _M_pNext(NULL), _M_refCount(0) { } + + /// <summary> + /// Constructs a <c>message</c> object. + /// </summary> + /// <param name="_P"> + /// The payload of this message. + /// </param> + /// <param name="_Id"> + /// The unique ID of this message. + /// </param> + /// <remarks> + /// The constructor that takes a pointer to a <c>message</c> object as an argument + /// throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if the parameter <paramref name="_Msg"/> is <c>NULL</c>. + /// </remarks> + /**/ + message(_Type const &_P, runtime_object_identity _Id) + : ::Concurrency::details::_Runtime_object(_Id), payload(_P), _M_pNext(NULL), _M_refCount(0) + { + } + + /// <summary> + /// Constructs a <c>message</c> object. + /// </summary> + /// <param name="_Msg"> + /// A reference or pointer to a <c>message</c> object. + /// </param> + /// <remarks> + /// The constructor that takes a pointer to a <c>message</c> object as an argument + /// throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if the parameter <paramref name="_Msg"/> is <c>NULL</c>. + /// </remarks> + /**/ + message(message const & _Msg) : payload(_Msg.payload), _M_pNext(NULL), _M_refCount(0) { } + + /// <summary> + /// Constructs a <c>message</c> object. + /// </summary> + /// <param name="_Msg"> + /// A reference or pointer to a <c>message</c> object. + /// </param> + /// <remarks> + /// This method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if the parameter <paramref name="_Msg"/> is <c>NULL</c>. + /// </remarks> + /**/ + message(_In_ message const * _Msg) : payload((_Msg == NULL) ? NULL : _Msg->payload), _M_pNext(NULL), _M_refCount(0) + { + if (_Msg == NULL) + { + throw std::invalid_argument("_Msg"); + } + } + + /// <summary> + /// Destroys the <c>message</c> object. + /// </summary> + /**/ + virtual ~message() { } + + /// <summary> + /// Returns the ID of the <c>message</c> object. + /// </summary> + /// <returns> + /// The <c>runtime_object_identity</c> of the <c>message</c> object. + /// </returns> + /**/ + runtime_object_identity msg_id() const + { + return _M_id; + } + + /// <summary> + /// The payload of the <c>message</c> object. + /// </summary> + /**/ + _Type const payload; + + /// <summary> + /// Adds to the reference count for the <c>message</c> object. Used for message blocks that + /// need reference counting to determine message lifetimes. + /// </summary> + /// <returns> + /// The new value of the reference count. + /// </returns> + /**/ + long add_ref() + { + return _InterlockedIncrement(&_M_refCount); + } + + /// <summary> + /// Subtracts from the reference count for the <c>message</c> object. Used for message blocks that + /// need reference counting to determine message lifetimes. + /// </summary> + /// <returns> + /// The new value of the reference count. + /// </returns> + /**/ + long remove_ref() + { + return _InterlockedDecrement(&_M_refCount); + } + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type type; + +private: + // The intrusive next pointer used by blocks that need + // to chain messages it's holding together + message * _M_pNext; + + // Avoid warnings about not generating assignment operators. + message<_Type> const &operator =(message<_Type> const &); + + // A reference count for the message + volatile long _M_refCount; +}; + +//************************************************************************** +// Message processor: +//************************************************************************** + +/// <summary> +/// The <c>message_processor</c> class is the abstract base class for processing of +/// <c>message</c> objects. There is no guarantee on the ordering of the messages. +/// </summary> +/// <typeparam name="_Type"> +/// The data type of the payload within messages handled by this <c>message_processor</c> object. +/// </typeparam> +/// <seealso cref="ordered_message_processor Class"/> +/**/ +template<class _Type> +class message_processor +{ +public: + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type type; + + /// <summary> + /// When overridden in a derived class, places messages into the block asynchronously. + /// </summary> + /// <param name="_Msg"> + /// A <c>message</c> object to send asynchronously. + /// </param> + /// <remarks> + /// Processor implementations should override this method. + /// </remarks> + /**/ + virtual void async_send(_Inout_opt_ message<_Type> * _Msg) = 0; + + /// <summary> + /// When overridden in a derived class, places messages into the block synchronously. + /// </summary> + /// <param name="_Msg"> + /// A <c>message</c> object to send synchronously. + /// </param> + /// <remarks> + /// Processor implementations should override this method. + /// </remarks> + /**/ + virtual void sync_send(_Inout_opt_ message<_Type> * _Msg) = 0; + + /// <summary> + /// When overridden in a derived class, waits for all asynchronous operations to complete. + /// </summary> + /// <remarks> + /// Processor implementations should override this method. + /// </remarks> + /**/ + virtual void wait() = 0; + +protected: + + /// <summary> + /// When overridden in a derived class, performs the forward processing of + /// messages into the block. Called once every time a new message is added and + /// the queue is found to be empty. + /// </summary> + /// <remarks> + /// Message block implementations should override this method. + /// </remarks> + /**/ + virtual void process_incoming_message() = 0; + + /// <summary> + /// Wrapper for <c>process_incoming_message</c> suitable for use as a argument to + /// <c>CreateThread</c> and other similar methods. + /// </summary> + /// <param name="_Data"> + /// A pointer to a message processor passed as a void pointer. + /// </param> + /**/ + static void __cdecl _Process_incoming_message_wrapper(void * _Data) + { + message_processor<_Type> * _PMessageProcessor = (message_processor<_Type> *) _Data; + _PMessageProcessor->process_incoming_message(); + } +}; + +/// <summary> +/// An <c>ordered_message_processor</c> is a <c>message_processor</c> that allows message blocks +/// to process messages in the order they were received. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of messages handled by the processor. +/// </typeparam> +/**/ +template<class _Type> +class ordered_message_processor : public message_processor<_Type> +{ +public: + /// <summary> + /// The signature of the callback method invoked while processing messages. + /// </summary> + /**/ + typedef std::tr1::function<void(message<_Type> *)> _Handler_method; + + /// <summary> + /// The signature of the callback method invoked while propagating messages. + /// </summary> + /**/ + typedef std::tr1::function<void(void)> _Propagator_method; + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef _Type type; + + /// <summary> + /// Constructs an <c>ordered_message_processor</c> object. + /// </summary> + /// <remarks> + /// This <c>ordered_message_processor</c> will not schedule asynchronous or synchronous + /// handlers until the <c>initialize</c> function is called. + /// </remarks> + /**/ + ordered_message_processor() : + _M_queuedDataCount(0), + _M_stopProcessing(1), + _M_lwtCount(0), + _M_pScheduler(NULL), + _M_pScheduleGroup(NULL), + _M_handler(nullptr), + _M_processor(nullptr), + _M_propagator(nullptr) + { + } + + /// <summary> + /// Destroys the <c>ordered_message_processor</c> object. + /// </summary> + /// <remarks> + /// Waits for all outstanding asynchronous operations before destroying the processor. + /// </remarks> + /**/ + virtual ~ordered_message_processor() + { + wait(); + } + + /// <summary> + /// Initializes the <c>ordered_message_processor</c> object with the appropriate + /// callback function, scheduler and schedule group. + /// </summary> + /// <param name="_PScheduler"> + /// A pointer to the scheduler to be used for scheduling light-weight tasks. + /// </param> + /// <param name="_PScheduleGroup"> + /// A pointer to the schedule group to be used for scheduling light-weight tasks. + /// </param> + /// <param name="_Handler"> + /// The handler functor invoked during callback. + /// </param> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + void initialize(_Inout_opt_ Scheduler * _PScheduler, _Inout_opt_ ScheduleGroup * _PScheduleGroup, _Handler_method const& _Handler) + { + _M_pScheduler = _PScheduler; + _M_pScheduleGroup = _PScheduleGroup; + _M_handler = _Handler; + _M_stopProcessing = 0; + } + + /// <summary> + /// Initialize batched message processing + /// </summary> + /// <param name="_Processor"> + /// The processor functor invoked during callback. + /// </param> + /// <param name="_Propagator"> + /// The propagator functor invoked during callback. + /// </param> + virtual void initialize_batched_processing(_Handler_method const& _Processor, _Propagator_method const& _Propagator) + { + _M_processor = _Processor; + _M_propagator = _Propagator; + } + + /// <summary> + /// Synchronously queues up messages and starts a processing task, if this has not been done + /// already. + /// </summary> + /// <param name="_Msg"> + /// A pointer to a message. + /// </param> + /**/ + virtual void sync_send(_Inout_opt_ message<_Type> * _Msg) + { + if (_M_handler == NULL) + { + throw invalid_operation("sync_send called without registering a callback"); + } + + _Sync_send_helper(_Msg); + } + + /// <summary> + /// Asynchronously queues up messages and starts a processing task, if this has not been done + /// already. + /// </summary> + /// <param name="_Msg"> + /// A pointer to a message. + /// </param> + /**/ + virtual void async_send(_Inout_opt_ message<_Type> * _Msg) + { + if (_M_handler == NULL) + { + throw invalid_operation("async_send called without registering a callback"); + } + + // + // If there is a message to send, enqueue it in the processing queue. + // async_send can be sent a NULL message if the block wishes to reprocess + // the messages that are in its queue. For example, an unbounded_buffer + // that has its head node released after reservation. + // + if (_Msg != NULL) + { + _M_queuedMessages.push(_Msg); + } + + if (_InterlockedIncrement(&_M_queuedDataCount) == 1) + { + // Indicate that an LWT is in progress. This will cause the + // destructor to block. + _InterlockedIncrement(&_M_lwtCount); + + if (_M_stopProcessing == 0) + { + _CONCRT_ASSERT(_M_lwtCount > 0); + + _Trace_agents(AGENTS_EVENT_SCHEDULE, ::Concurrency::details::_Trace_agents_get_id(this)); + + TaskProc _Proc = &::Concurrency::ordered_message_processor<_Type>::_Process_incoming_message_wrapper; +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + if (_M_pScheduleGroup != NULL) + { + _M_pScheduleGroup->ScheduleTask(_Proc, this); + } + else if (_M_pScheduler != NULL) + { + _M_pScheduler->ScheduleTask(_Proc, this); + } + else + { +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + ::Concurrency::details::_CurrentScheduler::_ScheduleTask(_Proc, this); +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + // The LWT will decrement _M_lwtCount. + return; + } + + // If we get here then no task was scheduled. Decrement LWT count to reflect this fact + _InterlockedDecrement(&_M_lwtCount); + } + } + + /// <summary> + /// A processor-specific spin wait used in destructors of message blocks to make sure + /// that all asynchronous processing tasks have time to finish before destroying the block. + /// </summary> + /**/ + virtual void wait() + { + // Cease processing of any new messages + _InterlockedIncrement(&_M_stopProcessing); + + // This spin makes sure all previously initiated message processings + // will still process correctly. As soon as this count reaches zero, we can + // procede with the message block destructor. + ::Concurrency::details::_SpinWaitBackoffNone spinWait(::Concurrency::details::_Context::_Yield); + while(_M_lwtCount != 0) + { + spinWait._SpinOnce(); + } + + // Synchronize with sync_send + { + _NR_lock _Lock(_M_asyncSendLock); + _Clear_queued_messages(); + } + + } + +protected: + + /// <summary> + /// The processing function that is called asynchronously. It dequeues messages and begins + /// processing them. + /// </summary> + /**/ + virtual void process_incoming_message() + { + _Trace_agents(AGENTS_EVENT_START, ::Concurrency::details::_Trace_agents_get_id(this)); + long _Count = _Process_message_helper(); + _Trace_agents(AGENTS_EVENT_END, ::Concurrency::details::_Trace_agents_get_id(this), _Count); + + // Indicate that an LWT completed + _InterlockedDecrement(&_M_lwtCount); + + // Do not access any members here. If the count goes to + // 0 as a result of the above decrement, the object + // could be immediately deleted. + } + + private: + + void _Clear_queued_messages() + { + message<_Type> * _Msg = NULL; + while (_M_queuedMessages.try_pop(_Msg)) + { + delete _Msg; + } + } + + void _Sync_send_helper(message<_Type> * _Msg) + { + _NR_lock _Lock(_M_asyncSendLock); + + // Message block destructors sets the _M_stopProcessing flag to stop + // processing any more messages. This is required to guarantee + // that the destructor's wait_for_async_sends will complete + if (_M_stopProcessing == 0) + { + if (_M_queuedDataCount > 0) + { + long _Count = _InterlockedExchange((volatile long *) &_M_queuedDataCount, 0); + _Invoke_handler(_Count); + } + + _Invoke_handler(_Msg); + } + else + { + // Destructor is running. Do not process the message + // Delete the msg, if any. + if (_Msg != NULL) + { + delete _Msg; + } + } + + } + + // Helper function to dequeue and process messages to any targets + long _Process_message_helper() + { + _NR_lock _Lock(_M_asyncSendLock); + + long _Messages_processed = 0; + + // Do batched processing of messages + // Read off the number of messages to process in this iteration by snapping a count + volatile long _Count = _M_queuedDataCount; + bool _StopProcessing = false; + + // This count could be 0 if there was both a synchronous and asynchronous + // send occuring. One of them could have sent all of the messages for the other + while (_Count > 0) + { + // Process _Count number of messages + _Invoke_handler(_Count); + _Messages_processed += _Count; + + // Subtract the count and see if there are new things to process + volatile long _Orig = _InterlockedExchangeAdd((volatile long *) &_M_queuedDataCount, -_Count); + _CONCRT_ASSERT(_Orig >= _Count); + if (_Orig == _Count) + { + // Because _Count did not change, we processed everything there is to process + break; + } + + if (_StopProcessing) + { + break; + } + + // After reading the flag process the currently queued messages + // Any messages received after we observe this flag (to be set) will not + // be processed. + _StopProcessing = (_M_stopProcessing == 0) ? false : true; + + // Snap the count and try to process more + _Count = _M_queuedDataCount; + } + + return _Messages_processed; + } + + // Invoke the handler in the message block for the given + // count + void _Invoke_handler(long _Count) + { + // Process _Count number of messages + for(int _I = 0; _I < _Count; _I++) + { + message<_Type> * _Msg = NULL; + _M_queuedMessages.try_pop(_Msg); + if (_M_processor == NULL) + { + // If a processor function does not exist, the message processor is using single + // message processing rather than batched processing. There should also be no + // propagator function defined in this case. + _CONCRT_ASSERT(_M_propagator == NULL); + _M_handler(_Msg); + } + else + { + // Use the batched message processing function + _M_processor(_Msg); + } + } + + // Call the handler which propagates the message(s) + if (_M_propagator != NULL) + { + _M_propagator(); + } + } + + // Invoke the message block handler for the given message + void _Invoke_handler(message<_Type> * _Msg) + { + if (_M_processor == NULL) + { + // If a processor function does not exist, the message processor is using single + // message processing rather than batched processing. There should also be no + // propagator function defined in this case. + _CONCRT_ASSERT(_M_propagator == NULL); + _M_handler(_Msg); + } + else + { + // Use the batched message processing function + _M_processor(_Msg); + + // Call the handler which propagates the message(s) + if (_M_propagator != NULL) + { + _M_propagator(); + } + } + } + + private: + /// <summary> + /// A queue of the messages + /// </summary> + /**/ + concurrent_queue<message<_Type> *> _M_queuedMessages; + + /// <summary> + /// A lock to use for queueing incoming messages. + /// </summary> + /**/ + ::Concurrency::details::_NonReentrantPPLLock _M_asyncSendLock; + + /// <summary> + /// A count of the current number of messages to process. Used as a flag + /// to see if a new process message task needs to be created. + /// </summary> + /**/ + volatile long _M_queuedDataCount; + + /// <summary> + /// The scheduler to process messages on + /// </summary> + /**/ + Scheduler * _M_pScheduler; + + /// <summary> + /// The schedule group to process messages on + /// </summary> + /**/ + ScheduleGroup * _M_pScheduleGroup; + + /// <summary> + /// A flag set in the destructor of a block to cease processing of new messages. + /// This is required to guarantee that _M_queuedDataCount will get to 0 eventually. + /// </summary> + /**/ + volatile long _M_stopProcessing; + + /// <summary> + /// A counter to indicate the number of outstanding LWTs + /// </summary> + /**/ + volatile long _M_lwtCount; + + /// <summary> + /// A message handler object which exposes the callback to be invoked + /// </summary> + /**/ + _Handler_method _M_handler; + + /// <summary> + /// A message processing object which exposes the callback to be invoked + /// </summary> + /**/ + _Handler_method _M_processor; + + /// <summary> + /// A message propagating object which exposes the callback to be invoked + /// </summary> + /**/ + _Propagator_method _M_propagator; +}; + +/// <summary> +/// The <c>ITarget</c> class is the interface for all target blocks. Target blocks +/// consume messages offered to them by <c>ISource</c> blocks. +/// </summary> +/// <typeparam name="_Type"> +/// The data type of the payload within the messages accepted by the target block. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="ISource Class"/> +/**/ +template<class _Type> +class ITarget +{ + // + // ISource<T> is a friend class because calls to Source->link_target() + // and Source->unlink_target() need to call their respective + // Target->link_source() and Target->unlink_source() on the block they are + // linking/unlinking. Those functions are private here because we don't + // want users calling link_source() or unlink_source() directly. link_source/ + // unlink_source don't call respective link_target/unlink_target because an + // infinite loop would occur. + // + friend class ISource<_Type>; + +public: + /// <summary> + /// Destroys the <c>ITarget</c> object. + /// </summary> + /**/ + virtual ~ITarget() {} + + // It is important that calls to propagate do *not* take the same lock on an + // internal message structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + /// <summary> + /// When overridden in a derived class, asynchronously passes a message from a source block to + /// this target block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if either the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>. + /// </remarks> + /**/ + virtual message_status propagate(_Inout_opt_ message<_Type> * _PMessage, _Inout_opt_ ISource<_Type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, synchronously passes a message to the target block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if either the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>. + /// <para>Using the <c>send</c> method outside of message initiation and to propagate messages + /// within a network is dangerous and can lead to deadlock.</para> + /// <para>When <c>send</c> returns, the message has either already been accepted, and transferred into + /// the target block, or it has been declined by the target.</para> + /// </remarks> + /**/ + virtual message_status send(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, returns true or false depending on whether the + /// message block accepts messages offered by a source that is not linked to it. If the overridden method returns + /// <c>true</c>, the target cannot postpone an offered message, as consumption of a postponed message + /// at a later time requires the source to be identified in its sourse link registry. + /// </summary> + /// <returns> + /// <c>true</c> if the block can accept message from a source that is not linked to it + /// <c>false</c> otherwise. + /// </returns> + /**/ + virtual bool supports_anonymous_source() + { + return false; + } + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type type; + + /// <summary> + /// The signature of any method used by the block that returns a <c>bool</c> value to determine + /// whether an offered message should be accepted. + /// </summary> + /**/ + typedef std::tr1::function<bool(_Type const&)> filter_method; + +protected: + + /// <summary> + /// When overridden in a derived class, links a specified source block to this <c>ITarget</c> block. + /// </summary> + /// <param name="_PSource"> + /// The <c>ISource</c> block being linked to this <c>ITarget</c> block. + /// </param> + /// <remarks> + /// This function should not be called directly on an <c>ITarget</c> block. Blocks should be connected together + /// using the <c>link_target</c> method on <c>ISource</c> blocks, which will invoke the <c>link_source</c> method + /// on the corresponding target. + /// </remarks> + /**/ + virtual void link_source(_Inout_ ISource<_Type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, unlinks a specified source block from this <c>ITarget</c> block. + /// </summary> + /// <param name="_PSource"> + /// The <c>ISource</c> block being unlinked from this <c>ITarget</c> block. + /// </param> + /// <remarks> + /// This function should not be called directly on an <c>ITarget</c> block. Blocks should be disconnected + /// using the <c>unlink_target</c> or <c>unlink_targets</c> methods on <c>ISource</c> blocks, which will invoke + /// the <c>unlink_source</c> method on the corresponding target. + /// </remarks> + /**/ + virtual void unlink_source(_Inout_ ISource<_Type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, unlinks all source blocks from this <c>ITarget</c> block. + /// </summary> + /**/ + virtual void unlink_sources() = 0; +}; + +/// <summary> +/// The <c>ISource</c> class is the interface for all source blocks. Source blocks +/// propagate messages to <c>ITarget</c> blocks. +/// </summary> +/// <typeparam name="_Type"> +/// The data type of the payload within the messages produced by the source block. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="ITarget Class"/> +/**/ +template<class _Type> +class ISource +{ +public: + /// <summary> + /// Destroys the <c>ISource</c> object. + /// </summary> + /**/ + virtual ~ISource() {} + + /// <summary> + /// When overridden in a derived class, links a target block to this <c>ISource</c> block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block being linked to this <c>ISource</c> block. + /// </param> + /**/ + virtual void link_target(_Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, unlinks a target block from this <c>ISource</c> block, + /// if found to be previously linked. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block being unlinked from this <c>ISource</c> block. + /// </param> + /**/ + virtual void unlink_target(_Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, unlinks all target blocks from this + /// <c>ISource</c> block. + /// </summary> + /**/ + virtual void unlink_targets() = 0; + + /// <summary> + /// When overridden in a derived class, accepts a message that was offered by this <c>ISource</c> block, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>accept</c> method. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>accept</c> method is called by a target while a message is being offered by this <c>ISource</c> block. + /// The message pointer returned may be different from the one passed into the <c>propagate</c> method + /// of the <c>ITarget</c> block, if this source decides to make a copy of the message. + /// </remarks> + /**/ + virtual message<_Type> * accept(runtime_object_identity _MsgId, _Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, reserves a message previously offered by this <c>ISource</c> block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>reserve</c> method. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. Reservations can fail + /// for many reasons, including: the message was already reserved or accepted by another target, the source could + /// deny reservations, and so forth. + /// </returns> + /// <remarks> + /// After you call <c>reserve</c>, if it succeeds, you must call either <c>consume</c> or <c>release</c> + /// in order to take or give up possession of the message, respectively. + /// </remarks> + /**/ + virtual bool reserve(runtime_object_identity _MsgId, _Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, consumes a message previously offered by this <c>ISource</c> block + /// and successfully reserved by the target, transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>consume</c> method. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>consume</c> method is similar to <c>accept</c>, but must always be preceded by a call to <c>reserve</c> that + /// returned <c>true</c>. + /// </remarks> + /**/ + virtual message<_Type> * consume(runtime_object_identity _MsgId, _Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, releases a previous successful message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>release</c> method. + /// </param> + /**/ + virtual void release(runtime_object_identity _MsgId, _Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, acquires a reference count on this <c>ISource</c> block, to prevent deletion. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being linked to this source + /// during the <c>link_target</c> method. + /// </remarks> + /**/ + virtual void acquire_ref(_Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// When overridden in a derived class, releases a reference count on this <c>ISource</c> block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being unlinked from this source. + /// The source block is allowed to release any resources reserved for the target block. + /// </remarks> + /**/ + virtual void release_ref(_Inout_ ITarget<_Type> * _PTarget) = 0; + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type source_type; + +protected: + /// <summary> + /// Links this source to a target. + /// </summary> + /// <param name="_PLinkFrom"> + /// A pointer to the target. + /// </param> + /// <remarks> + /// This function definition is required because ISource blocks the need to call + /// Target->link_source(), which is a private memeber of ITarget. ISource is + /// declared as a friend class, so this is an way for derived classes of ISource + /// to properly link/unlink their targets during link_target(), unlink_target() and + /// unlink_targets() + /// </remarks> + /**/ + void _Invoke_link_source(ITarget<_Type> * _PLinkFrom) + { + _PLinkFrom->link_source(this); + } + + /// <summary> + /// Unlinks this source from a target. + /// </summary> + /// <param name="_PUnlinkFrom"> + /// A pointer to the target. + /// </param> + /// <remarks> + /// This function definition is required because ISource blocks need to call + /// Target->unlink_source(), which is a private memeber of ITarget. ISource is + /// declared as a friend class, so this is an way for derived classes of ISource + /// to properly link/unlink their targets during link_target(), unlink_target() and + /// unlink_targets() + /// </remarks> + /**/ + void _Invoke_unlink_source(ITarget<_Type> * _PUnlinkFrom) + { + _PUnlinkFrom->unlink_source(this); + } +}; + +//************************************************************************** +// Target Block: +//************************************************************************** + +/// <summary> +/// The <c>target_block</c> class is an abstract base class that provides basic link management +/// functionality and error checking for target only blocks. +/// </summary> +/// <typeparam name="_SourceLinkRegistry"> +/// The link registry to be used for holding the source links. +/// </typeparam> +/// <typeparam name="_MessageProcessorType"> +/// The processor type for message processing. +/// </typeparam> +/// <seealso cref="ITarget Class"/> +/**/ +template<class _SourceLinkRegistry, + class _MessageProcessorType = ordered_message_processor<typename _SourceLinkRegistry::type::source_type>> +class target_block : public ITarget<typename _SourceLinkRegistry::type::source_type> +{ +public: + + /// <summary> + /// The type of the payload for the incoming messages to this <c>target_block</c> object. + /// </summary> + /**/ + typedef typename _SourceLinkRegistry::type::source_type _Source_type; + + /// <summary> + /// The type of the <c>source_link_manager</c> this <c>target_block</c> object. + /// </summary> + /**/ + typedef source_link_manager<_SourceLinkRegistry> _SourceLinkManager; + + /// <summary> + /// The type of the iterator for the <c>source_link_manager</c> for this <c>target_block</c> object. + /// </summary> + /**/ + typedef typename _SourceLinkManager::iterator source_iterator; + + /// <summary> + /// Constructs a <c>target_block</c> object. + /// </summary> + /**/ + target_block() : _M_pFilter(NULL), _M_fDeclineMessages(false) + { + _Trace_agents(AGENTS_EVENT_CREATE, + ::Concurrency::details::_Trace_agents_get_id(this), + ::Concurrency::details::_Trace_agents_get_id(&_M_messageProcessor)); + } + + /// <summary> + /// Destroys the <c>target_block</c> object. + /// </summary> + /**/ + virtual ~target_block() + { + // All sources should have been unlinked + _CONCRT_ASSERT(_M_connectedSources.count() == 0); + delete _M_pFilter; + + _Trace_agents(AGENTS_EVENT_DESTROY, ::Concurrency::details::_Trace_agents_get_id(this)); + } + + /// <summary> + /// Asynchronously passes a message from a source block to this target block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// <para> The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if either the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>.</para> + /// </remarks> + /**/ + virtual message_status propagate(_Inout_opt_ message<_Source_type> * _PMessage, _Inout_opt_ ISource<_Source_type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by <c>consume</c> and the LWT. Doing so could + // result in a deadlock. + + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + if (_M_fDeclineMessages) + { + return declined; + } + + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + return propagate_message(_PMessage, _PSource); + } + + /// <summary> + /// Synchronously passes a message from a source block to this target block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if either the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>. + /// <para>Using the <c>send</c> method outside of message initiation and to propagate messages + /// within a network is dangerous and can lead to deadlock.</para> + /// <para>When <c>send</c> returns, the message has either already been accepted, and transferred into + /// the target block, or it has been declined by the target.</para> + /// </remarks> + /**/ + virtual message_status send(_Inout_ message<_Source_type> * _PMessage, _Inout_ ISource<_Source_type> * _PSource) + { + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + if (_M_fDeclineMessages) + { + return declined; + } + + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + return send_message(_PMessage, _PSource); + } + +protected: + + /// <summary> + /// When overridden in a derived class, this method asynchronously passes a message from an <c>ISource</c> + /// block to this <c>target_block</c> object. It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Source_type> * _PMessage, _Inout_ ISource<_Source_type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, this method synchronously passes a message from an <c>ISource</c> + /// block to this <c>target_block</c> object. It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// By default, this block returns <c>declined</c> unless overridden by a derived class. + /// </remarks> + /**/ + virtual message_status send_message(_Inout_ message<_Source_type> *, _Inout_ ISource<_Source_type> *) + { + // By default we do not allow send() + return declined; + } + + /// <summary> + /// Links a specified source block to this <c>target_block</c> object. + /// </summary> + /// <param name="_PSource"> + /// A pointer to the <c>ISource</c> block that is to be linked. + /// </param> + /// <remarks> + /// This function should not be called directly on a <c>target_block</c> object. Blocks should be connected together + /// using the <c>link_target</c> method on <c>ISource</c> blocks, which will invoke the <c>link_source</c> method + /// on the corresponding target. + /// </remarks> + /**/ + virtual void link_source(_Inout_ ISource<_Source_type> * _PSource) + { + _M_connectedSources.add(_PSource); + _Trace_agents(AGENTS_EVENT_LINK, + ::Concurrency::details::_Trace_agents_get_id(_PSource), + ::Concurrency::details::_Trace_agents_get_id(this)); + } + + /// <summary> + /// Unlinks a specified source block from this <c>target_block</c> object. + /// </summary> + /// <param name="_PSource"> + /// A pointer to the <c>ISource</c> block that is to be unlinked. + /// </param> + /// This function should not be called directly on n <c>target_block</c> object. Blocks should be disconnected + /// using the <c>unlink_target</c> or <c>unlink_targets</c> methods on <c>ISource</c> blocks, which will invoke + /// the <c>unlink_source</c> method on the corresponding target. + /**/ + virtual void unlink_source(_Inout_ ISource<_Source_type> * _PSource) + { + _Trace_agents(AGENTS_EVENT_UNLINK, + ::Concurrency::details::_Trace_agents_get_id(_PSource), + ::Concurrency::details::_Trace_agents_get_id(this)); + + _M_connectedSources.remove(_PSource); + } + + /// <summary> + /// Unlinks all source blocks from this <c>target_block</c> object. + /// </summary> + /**/ + virtual void unlink_sources() + { + for (source_iterator _Iter = _M_connectedSources.begin(); *_Iter != NULL; ++_Iter) + { + ISource<_Source_type> * _PSource = *_Iter; + _PSource->unlink_target(this); + } + } + + /// <summary> + /// When overridden in a derived class, processes a message that was accepted by this <c>target_block</c> object. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the message that is to be handled. + /// </param> + /**/ + virtual void process_message(message<_Source_type> *) + { + } + + // + // Utility routines + // + + /// <summary> + /// Registers a filter method that will be invoked on + /// every message received. + /// </summary> + /// <param name="_Filter"> + /// The filter method. + /// </param> + /**/ + void register_filter(filter_method const& _Filter) + { + if (_Filter != NULL) + { + _M_pFilter = new filter_method(_Filter); + } + } + + /// <summary> + /// Indicates to the block that new messages should be declined. + /// </summary> + /// <remarks> + /// This method is called by the destructor to ensure that new messages are declined while destruction is in progress. + /// </remarks> + /**/ + void decline_incoming_messages() + { + _M_fDeclineMessages = true; + } + + /// <summary> + /// Initializes the base object. Specifically, the <c>message_processor</c> object needs + /// to be initialized. + /// </summary> + /// <param name="_PScheduler"> + /// The scheduler to be used for scheduling tasks. + /// </param> + /// <param name="_PScheduleGroup"> + /// The schedule group to be used for scheduling tasks. + /// </param> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + void initialize_target(_Inout_opt_ Scheduler * _PScheduler = NULL, _Inout_opt_ ScheduleGroup * _PScheduleGroup = NULL) + { + // Register a callback with the processor + _M_messageProcessor.initialize(_PScheduler, _PScheduleGroup, + // Processing and Propagating function used by ordered_message_processors + [this](message<_Source_type> * _PMessage) + { + // Handle message by calling process_message to maintain CRT100 compatibility + this->process_message(_PMessage); + }); + + // Register this target block as the owner of the connected sources + _M_connectedSources.register_target_block(this); + } + + /// <summary> + /// Enables batched processing for this block. + /// </summary> + /**/ + void enable_batched_processing() + { + _M_messageProcessor.initialize_batched_processing( + // Processing function used by CRT110 + [this](message<_Source_type> * _PMessage) + { + // Handle message through new process_input_message to use CRT110 batch processing + this->process_input_messages(_PMessage); + }, nullptr); + } + + /// <summary> + /// Asynchronously sends a message for processing. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the message being sent. + /// </param> + /**/ + void async_send(_Inout_opt_ message<_Source_type> * _PMessage) + { + _M_messageProcessor.async_send(_PMessage); + } + + /// <summary> + /// Synchronously send a message for processing. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the message being sent. + /// </param> + /**/ + void sync_send(_Inout_opt_ message<_Source_type> * _PMessage) + { + _M_messageProcessor.sync_send(_PMessage); + } + + /// <summary> + /// Waits for all asynchronous propagations to complete. + /// </summary> + /// <remarks> + /// This method is used by message block destructors to ensure all asynchronous operations + /// have had time to finish before destroying the block. + /// </remarks> + /**/ + void wait_for_async_sends() + { + // Decline new messages to ensure that messages are not dropped during the wait + decline_incoming_messages(); + + _M_messageProcessor.wait(); + } + + /// <summary> + /// Unlinks all sources after waiting for outstanding asynchronous send operations to complete. + /// </summary> + /// <remarks> + /// All target blocks should call this routine to remove the sources in their destructor. + /// </remarks> + /**/ + void remove_sources() + { + wait_for_async_sends(); + + unlink_sources(); + } + + /// <summary> + /// Processes messages that are received as inputs. + /// </summary> + /**/ + virtual void process_input_messages(_Inout_ message<_Source_type> * _PMessage) + { + throw invalid_operation("To use batched processing, you must override process_input_messages in the message block."); + } + + /// <summary> + /// The container for all the sources connected to this block. + /// </summary> + /**/ + _SourceLinkManager _M_connectedSources; + + /// <summary> + /// The filter function which determines whether offered messages should be accepted. + /// </summary> + /**/ + filter_method * _M_pFilter; + + /// <summary> + /// A <c>bool</c> that is set to indicate that all messages should be declined + /// in preparation for deleting the block + /// <summary> + /**/ + bool _M_fDeclineMessages; + + /// <summary> + /// The <c>message_processor</c> for this <c>target_block</c>. + /// <summary> + /**/ + _MessageProcessorType _M_messageProcessor; +}; + +//************************************************************************** +// Source Block: +//************************************************************************** + +/// <summary> +/// The <c>source_block</c> class is an abstract base class for source-only blocks. The class +/// provides basic link management functionality as well as common error checks. +/// </summary> +/// <typeparam name="_TargetLinkRegistry"> +/// Link registry to be used for holding the target links. +/// </typeparam> +/// <typeparam name="_MessageProcessorType"> +/// Processor type for message processing. +/// </typeparam> +/// <remarks> +/// Message blocks should derive from this block to take advantage of link management and +/// synchronization provided by this class. +/// </remarks> +/// <seealso cref="ISource Class"/> +/**/ +template<class _TargetLinkRegistry, + class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>> +class source_block : public ISource<typename _TargetLinkRegistry::type::type> +{ +public: + + /// <summary> + /// The payload type of messages handled by this <c>source_block</c>. + /// </summary> + /**/ + typedef typename _TargetLinkRegistry::type::type _Target_type; + + /// <summary> + /// The iterator to walk the connected targets. + /// </summary> + /**/ + typedef typename _TargetLinkRegistry::iterator target_iterator; + + /// <summary> + /// Constructs a <c>source_block</c> object. + /// </summary> + /**/ + source_block() : + _M_pReservedFor(NULL), + _M_reservedId(-1), + _M_referenceCount(0) + { + _Trace_agents(AGENTS_EVENT_CREATE, + ::Concurrency::details::_Trace_agents_get_id(this), + ::Concurrency::details::_Trace_agents_get_id(&_M_messageProcessor)); + } + + /// <summary> + /// Destroys the <c>source_block</c> object. + /// </summary> + /**/ + virtual ~source_block() + { + // All targets should have been unlinked + _CONCRT_ASSERT(_M_connectedTargets.count() == 0); + + _Trace_agents(AGENTS_EVENT_DESTROY, ::Concurrency::details::_Trace_agents_get_id(this)); + } + + /// <summary> + /// Links a target block to this <c>source_block</c> object. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to link to this <c>source_block</c> object. + /// </param> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// </remarks> + /**/ + virtual void link_target(_Inout_ ITarget<_Target_type> * _PTarget) + { + _R_lock _Lock(_M_internalLock); + + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + _M_connectedTargets.add(_PTarget); + _Invoke_link_source(_PTarget); + link_target_notification(_PTarget); + } + + /// <summary> + /// Unlinks a target block from this <c>source_block</c> object. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to unlink from this <c>source_block</c> object. + /// </param> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// </remarks> + /**/ + virtual void unlink_target(_Inout_ ITarget<_Target_type> * _PTarget) + { + _R_lock _Lock(_M_internalLock); + + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (_M_connectedTargets.remove(_PTarget)) + { + // We were able to remove the target from our list. + // Inform the target to unlink from us + _Invoke_unlink_source(_PTarget); + } + } + + /// <summary> + /// Unlinks all target blocks from this <c>source_block</c> object. + /// </summary> + /**/ + virtual void unlink_targets() + { + _R_lock _Lock(_M_internalLock); + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Target_type> * _PTarget = *_Iter; + _CONCRT_ASSERT(_PTarget != NULL); + + unlink_target(_PTarget); + } + + // All the targets should be unlinked. + _CONCRT_ASSERT(_M_connectedTargets.count() == 0); + } + + /// <summary> + /// Accepts a message that was offered by this <c>source_block</c> object, transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>accept</c> method. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// <para> + /// The <c>accept</c> method is called by a target while a message is being offered by this <c>ISource</c> block. + /// The message pointer returned may be different from the one passed into the <c>propagate</c> method + /// of the <c>ITarget</c> block, if this source decides to make a copy of the message. + /// </para> + /// </remarks> + /**/ + virtual message<_Target_type> * accept(runtime_object_identity _MsgId, _Inout_ ITarget<_Target_type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + // Assert if the target is not connected + _CONCRT_ASSERT(_M_connectedTargets.contains(_PTarget)); + + return accept_message(_MsgId); + } + + /// <summary> + /// Reserves a message previously offered by this <c>source_block</c> object. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>reserve</c> method. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. Reservations can fail + /// for many reasons, including: the message was already reserved or accepted by another target, the source could + /// deny reservations, and so forth. + /// </returns> + /// <remarks> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// <para> + /// After you call <c>reserve</c>, if it succeeds, you must call either <c>consume</c> or <c>release</c> + /// in order to take or give up possession of the message, respectively. + /// </para> + /// </remarks> + /**/ + virtual bool reserve(runtime_object_identity _MsgId, _Inout_ ITarget<_Target_type> * _PTarget) + { + _R_lock _Lock(_M_internalLock); + + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if ( _M_pReservedFor != NULL) + { + // Someone else is holding the reservation + return false; + } + + if (!reserve_message(_MsgId)) + { + // Failed to reserve the msg ID + return false; + } + + // Save the reserving target and the msg ID + _M_pReservedFor = _PTarget; + _M_reservedId = _MsgId; + + return true; + } + + /// <summary> + /// Consumes a message previously offered by this <c>source_block</c> object and successfully reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>consume</c> method. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// <para> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// </para> + /// <para> + /// The method throws a <see cref="bad_target Class">bad_target</see> exception if the parameter <paramref name="_PTarget"/> + /// does not represent the target that called <c>reserve</c>. + /// </para> + /// <para> + /// The <c>consume</c> method is similar to <c>accept</c>, but must always be preceded by a call to <c>reserve</c> that + /// returned <c>true</c>. + /// </para> + /// </remarks> + /**/ + virtual message<_Target_type> * consume(runtime_object_identity _MsgId, _Inout_ ITarget<_Target_type> * _PTarget) + { + _R_lock _Lock(_M_internalLock); + + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (_M_pReservedFor == NULL || _PTarget != _M_pReservedFor) + { + throw bad_target(); + } + + message<_Target_type> * _Msg = consume_message(_MsgId); + + if (_Msg != NULL) + { + // Clear the reservation + // _M_pReservedId is intentionally not reset so that it can assist in debugging + _M_pReservedFor = NULL; + + // Reservation is assumed to block propagation. Notify that propagation can now be resumed + resume_propagation(); + } + + return _Msg; + } + + /// <summary> + /// Releases a previous successful message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>release</c> method. + /// </param> + /// <remarks> + /// <para> + /// The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if the + /// parameter <paramref name="_PTarget"/> is <c>NULL</c>. + /// </para> + /// <para> + /// The method throws a <see cref="bad_target Class">bad_target</see> exception if the parameter <paramref name="_PTarget"/> + /// does not represent the target that called <c>reserve</c>. + /// </para> + /// </remarks> + /**/ + virtual void release(runtime_object_identity _MsgId, _Inout_ ITarget<_Target_type> * _PTarget) + { + _R_lock _Lock(_M_internalLock); + + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (_PTarget != _M_pReservedFor) + { + throw bad_target(); + } + + release_message(_MsgId); + + // Clear the reservation + // _M_pReservedId is intentionally not reset so that it can assist in debugging + _M_pReservedFor = NULL; + + // Reservation is assumed to block propagation. Notify that propagation can now be resumed + resume_propagation(); + } + + /// <summary> + /// Acquires a reference count on this <c>source_block</c> object, to prevent deletion. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being linked to this source + /// during the <c>link_target</c> method. + /// </remarks> + /**/ + virtual void acquire_ref(_Inout_ ITarget<_Target_type> *) + { + _InterlockedIncrement(&_M_referenceCount); + } + + /// <summary> + /// Releases a reference count on this <c>source_block</c> object. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being unlinked from this source. + /// The source block is allowed to release any resources reserved for the target block. + /// </remarks> + /**/ + virtual void release_ref(_Inout_ ITarget<_Target_type> * _PTarget) + { + if (_PTarget != NULL) + { + _R_lock _Lock(_M_internalLock); + + // We assume that each target would keep a single reference on its source, so + // we call unlink target notification on every release. Otherwise, we would be + // required to keep a reference count per target. + // Note: unlink_target_notification can check the value of this _PTarget pointer, but + // must not dereference it, as it may have already been deleted. + unlink_target_notification(_PTarget); + } + + _InterlockedDecrement(&_M_referenceCount); + + // It is *unsafe* to touch the "this" pointer after decrementing the reference count + } + +protected: + + // + // Protected methods that a derived class can override to customize + // the functionality + // + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>source_block</c> object. + /// </summary> + /// <param name="_PTarget"> + /// The <c>ITarget</c> block that was linked. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Target_type> *) + { + // By default, we restart propagation if there is no pending resrvation + if (_M_pReservedFor == NULL) + { + propagate_to_any_targets(NULL); + } + } + + /// <summary> + /// A callback that notifies that a target has been unlinked from this <c>source_block</c> object. + /// </summary> + /// <param name="_PTarget"> + /// The <c>ITarget</c> block that was unlinked. + /// </param> + /**/ + virtual void unlink_target_notification(_Inout_ ITarget<_Target_type> * _PTarget) + { + // At this point, the target has already been disconnected from the + // source. It is safe to check the value of this pointer, but not + // safe to dereference it, as it may have already been deleted. + + // If the target being unlinked is the one holding the reservation, + // release the reservation + if (_M_pReservedFor == _PTarget) + { + release(_M_reservedId, _PTarget); + } + } + + /// <summary> + /// When overridden in a derived class, accepts an offered message by the source. + /// Message blocks should override this method to validate the <paramref name="_MsgId"/> and + /// return a message. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /// <remarks> + /// To transfer ownership, the original message pointer should be returned. To maintain + /// ownership, a copy of message payload needs to be made and returned. + /// </remarks> + /**/ + virtual message<_Target_type> * accept_message(runtime_object_identity _MsgId) = 0; + + /// <summary> + /// When overridden in a derived class, reserves a message previously offered by this + /// <c>source_block</c> object. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) = 0; + + /// <summary> + /// When overridden in a derived class, consumes a message that was previously reserved. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Target_type> * consume_message(runtime_object_identity _MsgId) = 0; + + /// <summary> + /// When overridden in a derived class, releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) = 0; + + /// <summary> + /// When overridden in a derived class, resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() = 0; + + /// <summary> + /// Process input messages. This is only useful for propagator blocks, which derive from source_block + /// </summary> + /**/ + virtual void process_input_messages(_Inout_ message<_Target_type> * _PMessage) + { + // source_blocks do not need to process anything + } + + /// <summary> + /// Propagate messages to targets. + /// </summary> + /**/ + virtual void propagate_output_messages() + { + throw invalid_operation("To use batched processing, you must override propagate_output_messages in the message block."); + } + + /// <summary> + /// When overridden in a derived class, propagates the given message to any or all of the linked targets. + /// This is the main propagation routine for message blocks. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the message that is to be propagated. + /// </param> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<_Target_type> * _PMessage) + { + throw invalid_operation("To use ordered message processing, you must override propagate_to_any_targets in the message block."); + } + + // + // Utility routines + // + /// <summary> + /// Initializes the <c>message_propagator</c> within this <c>source_block</c>. + /// </summary> + /// <param name="_PScheduler"> + /// The scheduler to be used for scheduling tasks. + /// </param> + /// <param name="_PScheduleGroup"> + /// The schedule group to be used for scheduling tasks. + /// </param> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + void initialize_source(_Inout_opt_ Scheduler * _PScheduler = NULL, _Inout_opt_ ScheduleGroup * _PScheduleGroup = NULL) + { + // Register a callback + _M_messageProcessor.initialize(_PScheduler, _PScheduleGroup, + [this](message<_Target_type> * _PMessage) + { + this->_Handle_message(_PMessage); + }); + } + + /// <summary> + /// Enables batched processing for this block. + /// </summary> + /**/ + void enable_batched_processing() + { + // Register callbacks for CRT110 batched processing + _M_messageProcessor.initialize_batched_processing( + // Processing function used by CRT110 + [this](message<_Target_type> * _PMessage) + { + // Handle message through new process_input_message to use CRT110 batch processing + this->process_input_messages(_PMessage); + }, + [this](void) + { + this->_Propagate_message(); + }); + } + + /// <summary> + /// Synchronously queues up messages and starts a propagation task, if this has not been done + /// already. + /// </summary> + /// <param name="_Msg"> + /// A pointer to a <c>message</c> object to synchronously send. + /// </param> + /**/ + virtual void sync_send(_Inout_opt_ message<_Target_type> * _Msg) + { + // Caller shall not be holding any locks when calling this routine + _M_messageProcessor.sync_send(_Msg); + } + + /// <summary> + /// Asynchronously queues up messages and starts a propagation task, if this has not been done + /// already + /// </summary> + /// <param name="_Msg"> + /// A pointer to a <c>message</c> object to asynchronously send. + /// </param> + /**/ + virtual void async_send(_Inout_opt_ message<_Target_type> * _Msg) + { + _M_messageProcessor.async_send(_Msg); + } + + /// <summary> + /// Waits for all asynchronous propagations to complete. This propagator-specific spin wait is used + /// in destructors of message blocks to make sure that all asynchronous propagations have time to finish + /// before destroying the block. + /// </summary> + /**/ + void wait_for_outstanding_async_sends() + { + _M_messageProcessor.wait(); + } + + /// <summary> + /// Removes all target links for this source block. This should be called from the destructor. + /// </summary> + /**/ + void remove_targets() + { + // Wait for outstanding propagation to complete. + wait_for_outstanding_async_sends(); + + unlink_targets(); + + _Wait_on_ref(); + } + + // + // Protected members + // + + /// <summary> + /// Connected target that is holding a reservation + /// </summary> + /**/ + ITarget<_Target_type> * _M_pReservedFor; + + /// <summary> + /// Reserved message ID + /// </summary> + /**/ + runtime_object_identity _M_reservedId; + + /// <summary> + /// Connected targets + /// </summary> + /**/ + _TargetLinkRegistry _M_connectedTargets; + + /// <summary> + /// Processor used for asynchronous message handling + /// </summary> + /**/ + _MessageProcessorType _M_messageProcessor; + +private: + + /// Private methods + + + // Message handler callback for the propagator. Invokes propagate_to_any_targets + // which derived classes should implement. + /**/ + void _Handle_message(message<_Target_type> * _PMessage) + { + // Hold a lock to synchronize with unlink targets + _R_lock _Lock(_M_internalLock); + propagate_to_any_targets(_PMessage); + } + + // Message handler callback for the processor. Invokes process_input_messages + // which derived classes should implement. + /**/ + void _Process_message(message<_Target_type> * _PMessage) + { + // Don't need a lock to process the message + process_input_messages(_PMessage); + } + + // Message handler callback for the propagator. Invokes propagate_output_messages + // which derived classes should implement. + /**/ + void _Propagate_message() + { + // Hold a lock to synchronize with unlink targets + _R_lock _Lock(_M_internalLock); + propagate_output_messages(); + } + + // Wait for the reference on this block to drop to zero + /**/ + void _Wait_on_ref(long _RefCount = 0) + { + ::Concurrency::details::_SpinWaitBackoffNone spinWait; + while(_M_referenceCount != _RefCount) + { + spinWait._SpinOnce(); + } + } + + // Private Data members + + /// <summary> + /// Internal lock used for the following synchronization: + /// 1. Synchronize between link and unlink target + /// 2. Synchronize between propagate_to_any_targets and unlink_target + /// 3. Synchronize between reserve and consume/release + /// </summary> + /**/ + ::Concurrency::details::_ReentrantPPLLock _M_internalLock; + + volatile long _M_referenceCount; + +}; + +//************************************************************************** +// Propagator (source and target) Block: +//************************************************************************** +/// <summary> +/// The <c>propagator_block</c> class is an abstract base class for message blocks that are both a source and target. +/// It combines the functionality of both the <c>source_block</c> and <c>target_block</c> classes. +/// </summary> +/// <typeparam name="_TargetLinkRegistry"> +/// The link registry to be used for holding the target links. +/// </typeparam> +/// <typeparam name="_SourceLinkRegistry"> +/// The link registry to be used for holding the source links. +/// </typeparam> +/// <typeparam name="_MessageProcessorType"> +/// The processor type for message processing. +/// </typeparam> +/// <remarks> +/// To avoid multiple inheritance, the <c>propagator_block</c> class inherits from the <c>source_block</c> class and <c>ITarget</c> +/// abstract class. Most of the functionality in the <c>target_block</c> class is replicated here. +/// </remarks> +/// <seealso cref="source_block Class"/> +/// <seealso cref="ITarget Class"/> +/**/ +template<class _TargetLinkRegistry, class _SourceLinkRegistry, + class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>> +class propagator_block : public source_block<_TargetLinkRegistry, _MessageProcessorType>, public ITarget<typename _SourceLinkRegistry::type::source_type> +{ +public: + + /// <summary> + /// The type of the payload for the incoming message to this <c>propagator_block</c>. + /// </summary> + /**/ + typedef typename _SourceLinkRegistry::type::source_type _Source_type; + + /// <summary> + /// The type of the <c>source_link_manager</c> this <c>propagator_block</c>. + /// </summary> + /**/ + typedef source_link_manager<_SourceLinkRegistry> _SourceLinkManager; + + /// <summary> + /// The type of the iterator for the <c>source_link_manager</c> for this <c>propagator_block</c>. + /// </summary> + /**/ + typedef typename _SourceLinkManager::iterator source_iterator; + + /// <summary> + /// Constructs a <c>propagator_block</c> object. + /// </summary> + /**/ + propagator_block() : _M_pFilter(NULL), _M_fDeclineMessages(false) + { + } + + /// <summary> + /// Destroys a <c>propagator_block</c> object. + /// </summary> + /**/ + virtual ~propagator_block() + { + remove_network_links(); + + delete _M_pFilter; + } + + /// <summary> + /// Asynchronously passes a message from a source block to this target block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// The <c>propagate</c> method is invoked on a target block by a linked source block. It queues up an + /// asynchronous task to handle the message, if one is not already queued or executing. + /// <para> The method throws an <see cref="invalid_argument Class">invalid_argument</see> exception + /// if either the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>.</para> + /// </remarks> + /**/ + virtual message_status propagate(_Inout_opt_ message<_Source_type> * _PMessage, _Inout_opt_ ISource<_Source_type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by <c>consume</c> and the LWT. Doing so could + // result in a deadlock. + + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + if (_M_fDeclineMessages) + { + return declined; + } + + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + return propagate_message(_PMessage, _PSource); + } + + /// <summary> + /// Synchronously initiates a message to this block. Called by an <c>ISource</c> block. + /// When this function completes, the message will already have propagated into the block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// This method throws an <see cref="invalid_argument Class">invalid_argument</see> exception if either + /// the <paramref name="_PMessage"/> or <paramref name="_PSource"/> parameter is <c>NULL</c>. + /// </remarks> + /**/ + virtual message_status send(_Inout_ message<_Source_type> * _PMessage, _Inout_ ISource<_Source_type> * _PSource) + { + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + if (_M_fDeclineMessages) + { + return declined; + } + + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + return send_message(_PMessage, _PSource); + } + +protected: + + /// <summary> + /// When overridden in a derived class, this method asynchronously passes a message from an <c>ISource</c> + /// block to this <c>propagator_block</c> object. It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Source_type> * _PMessage, _Inout_ ISource<_Source_type> * _PSource) = 0; + + /// <summary> + /// When overridden in a derived class, this method synchronously passes a message from an <c>ISource</c> + /// block to this <c>propagator_block</c> object. It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// By default, this block returns <c>declined</c> unless overridden by a derived class. + /// </remarks> + /**/ + virtual message_status send_message(_Inout_ message<_Source_type> *, _Inout_ ISource<_Source_type> *) + { + // By default we do not allow send() + return declined; + } + + /// <summary> + /// Links a specified source block to this <c>propagator_block</c> object. + /// </summary> + /// <param name="_PSource"> + /// A pointer to the <c>ISource</c> block that is to be linked. + /// </param> + /**/ + virtual void link_source(_Inout_ ISource<_Source_type> * _PSource) + { + _M_connectedSources.add(_PSource); + _Trace_agents(AGENTS_EVENT_LINK, + ::Concurrency::details::_Trace_agents_get_id(_PSource), + ::Concurrency::details::_Trace_agents_get_id(this)); + } + + /// <summary> + /// Unlinks a specified source block from this <c>propagator_block</c> object. + /// </summary> + /// <param name="_PSource"> + /// A pointer to the <c>ISource</c> block that is to be unlinked. + /// </param> + /**/ + virtual void unlink_source(_Inout_ ISource<_Source_type> * _PSource) + { + _Trace_agents(AGENTS_EVENT_UNLINK, + ::Concurrency::details::_Trace_agents_get_id(_PSource), + ::Concurrency::details::_Trace_agents_get_id(this)); + + _M_connectedSources.remove(_PSource); + } + + /// <summary> + /// Unlinks all source blocks from this <c>propagator_block</c> object. + /// </summary> + /**/ + virtual void unlink_sources() + { + for (source_iterator _Iter = _M_connectedSources.begin(); *_Iter != NULL; ++_Iter) + { + ISource<_Source_type> * _PSource = *_Iter; + _PSource->unlink_target(this); + } + } + + // + // Utility routines + // + + /// <summary> + /// Process input messages. This is only useful for propagator blocks, which derive from source_block + /// </summary> + /**/ + virtual void process_input_messages(_Inout_ message<_Target_type> * _PMessage) + { + throw invalid_operation("To use batched processing, you must override process_input_messages in the message block."); + } + + /// <summary> + /// Initializes the base object. Specifically, the <c>message_processor</c> object needs + /// to be initialized. + /// </summary> + /// <param name="_PScheduler"> + /// The scheduler to be used for scheduling tasks. + /// </param> + /// <param name="_PScheduleGroup"> + /// The schedule group to be used for scheduling tasks. + /// </param> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + void initialize_source_and_target(_Inout_opt_ Scheduler * _PScheduler = NULL, _Inout_opt_ ScheduleGroup * _PScheduleGroup = NULL) + { + initialize_source(_PScheduler, _PScheduleGroup); + + // Register this propagator block as the owner of the connected sources + _M_connectedSources.register_target_block(this); + } + + /// <summary> + /// Registers a filter method that will be invoked on every received message. + /// </summary> + /// <param name="_Filter"> + /// The filter method. + /// </param> + /**/ + void register_filter(filter_method const& _Filter) + { + if (_Filter != NULL) + { + _M_pFilter = new filter_method(_Filter); + } + } + + /// <summary> + /// Indicates to the block that new messages should be declined. + /// </summary> + /// <remarks> + /// This method is called by the destructor to ensure that new messages are declined while destruction is in progress. + /// </remarks> + /**/ + void decline_incoming_messages() + { + _M_fDeclineMessages = true; + } + + /// <summary> + /// Removes all the source and target network links from this <c>propagator_block</c> object. + /// </summary> + /**/ + void remove_network_links() + { + // Decline messages while the links are being removed + decline_incoming_messages(); + + // Remove all the target links. This waits for + // all outstanding async propagation operations. + remove_targets(); + + // unlink all sources. The above steps guarantee that + // they can be removed safely. + unlink_sources(); + } + + /// <summary> + /// The container for all the sources connected to this block. + /// </summary> + /**/ + _SourceLinkManager _M_connectedSources; + + /// <summary> + /// The filter function which determines whether offered messages should be accepted. + /// </summary> + /**/ + filter_method * _M_pFilter; + + /// <summary> + /// A <c>bool</c> that is set to indicate that all messages should be declined + /// in preparation for deleting the block + /// <summary> + /**/ + volatile bool _M_fDeclineMessages; +}; + +//************************************************************************** +// Unbounded Buffers: +//************************************************************************** + +/// <summary> +/// An <c>unbounded_buffer</c> messaging block is a multi-target, multi-source, ordered +/// <c>propagator_block</c> capable of storing an unbounded number of messages. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the messages stored and propagated by the buffer. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="overwrite_buffer Class"/> +/// <seealso cref="single_assignment Class"/> +/**/ +template<class _Type> +class unbounded_buffer : public propagator_block<multi_link_registry<ITarget<_Type>>, multi_link_registry<ISource<_Type>>> +{ +public: + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer() : + _M_fForceRepropagation(false) + { + initialize_source_and_target(); + enable_batched_processing(); + } + + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer(filter_method const& _Filter) : + _M_fForceRepropagation(false) + { + initialize_source_and_target(); + enable_batched_processing(); + register_filter(_Filter); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>unbounded_buffer</c> object is scheduled. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer(Scheduler& _PScheduler) : + _M_fForceRepropagation(false) + { + initialize_source_and_target(&_PScheduler); + enable_batched_processing(); + } + + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>unbounded_buffer</c> messaging block is scheduled. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer(Scheduler& _PScheduler, filter_method const& _Filter) : + _M_fForceRepropagation(false) + { + initialize_source_and_target(&_PScheduler); + enable_batched_processing(); + register_filter(_Filter); + } + + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>unbounded_buffer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer(ScheduleGroup& _PScheduleGroup) : + _M_fForceRepropagation(false) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + enable_batched_processing(); + } + + /// <summary> + /// Constructs an <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>unbounded_buffer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>unbounded_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + unbounded_buffer(ScheduleGroup& _PScheduleGroup, filter_method const& _Filter) : + _M_fForceRepropagation(false) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + enable_batched_processing(); + register_filter(_Filter); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>unbounded_buffer</c> messaging block. + /// </summary> + /**/ + ~unbounded_buffer() + { + // Remove all links + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + } + + /// <summary> + /// Adds an item to the <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_Item"> + /// The item to add. + /// </param> + /// <returns> + /// <c>true</c> if the item was accepted, <c>false</c> otherwise. + /// </returns> + /**/ + bool enqueue(_Type const& _Item) + { + return Concurrency::send<_Type>(this, _Item); + } + + /// <summary> + /// Removes an item from the <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <returns> + /// The payload of the message removed from the <c>unbounded_buffer</c>. + /// </returns> + /**/ + _Type dequeue() + { + return receive<_Type>(this); + } + + +protected: + + // + // propagator_block protected function implementations + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>unbounded_buffer</c> messaging block. + /// It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by <c>consume</c> and the LWT. Doing so could + // result in a deadlock. + + message_status _Result = accepted; + + // Accept the message being propagated + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + async_send(_PMessage); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Synchronously passes a message from an <c>ISource</c> block to this <c>unbounded_buffer</c> messaging block. + /// It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status send_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + sync_send(_PMessage); + } + else + { + return missed; + } + + return accepted; + } + + /// <summary> + /// Overrides the <c>supports_anonymous_source</c> method to indicate that this block can + /// accept messages offered to it by a source that is not linked. + /// </summary> + /// <returns> + /// <c>true</c> because the block does not postpone offered messages. + /// </returns> + /**/ + virtual bool supports_anonymous_source() + { + return true; + } + + /// <summary> + /// Accepts a message that was offered by this <c>unbounded_buffer</c> messaging block, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_Type> * accept_message(runtime_object_identity _MsgId) + { + // + // Peek at the head message in the message buffer. If the IDs match + // dequeue and transfer ownership + // + message<_Type> * _Msg = NULL; + + if (_M_messageBuffer._Is_head(_MsgId)) + { + _Msg = _M_messageBuffer._Dequeue(); + } + + return _Msg; + } + + /// <summary> + /// Reserves a message previously offered by this <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // Allow reservation if this is the head message + return _M_messageBuffer._Is_head(_MsgId); + } + + /// <summary> + /// Consumes a message previously offered by the <c>unbounded_buffer</c> messaging block and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Type> * consume_message(runtime_object_identity _MsgId) + { + // By default, accept the message + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + // The head message is the one reserved. + if (!_M_messageBuffer._Is_head(_MsgId)) + { + throw message_not_found(); + } + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // If there are any messages in the buffer, propagate them out + if (_M_messageBuffer._Count() > 0) + { + // Set the flag to force a repropagation. This flag is cleared when a propagation happens + // The only functions that call this are release, consume, and link_target, all of which + // hold the internal lock, so the flag is guaranteed to be read by propagation, which also + // holds the same lock. + _M_fForceRepropagation = true; + + // async send a NULL value to initiate the repropagation + async_send(NULL); + } + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>unbounded_buffer</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Type> * _PTarget) + { + // If the message queue is blocked due to reservation + // there is no need to do any message propagation + if (_M_pReservedFor != NULL) + { + return; + } + + message<_Type> * _Msg = _M_messageBuffer._Peek(); + + if (_Msg != NULL) + { + // Propagate the head message to the new target + message_status _Status = _PTarget->propagate(_Msg, this); + + if (_Status == accepted) + { + // The target accepted the message, restart propagation. + _Propagate_priority_order(_M_messageBuffer); + } + + // If the status is anything other than accepted, then leave + // the message queue blocked. + } + } + + /// <summary> + /// Places the <c>message</c> <paramref name="_PMessage"/> in this <c>unbounded_buffer</c> messaging block and + /// tries to offer it to all of the linked targets. + /// </summary> + virtual void process_input_messages(_Inout_ message<_Type> * _PMessage) + { + if (_PMessage != NULL) + { + _M_processedMessages._Enqueue(_PMessage); + } + } + + /// <summary> + /// Places the <c>message</c> <paramref name="_PMessage"/> in this <c>unbounded_buffer</c> messaging block and + /// tries to offer it to all of the linked targets. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a <c>message</c> object that this <c>unbounded_buffer</c> has taken ownership of. + /// </param> + /// <remarks> + /// If another message is already ahead of this one in the <c>unbounded_buffer</c>, + /// propagation to linked targets will not occur until any earlier messages have been accepted + /// or consumed. The first linked target to successfully <c>accept</c> or <c>consume</c> the + /// message takes ownership, and no other target can then get the message. + /// </remarks> + /**/ + virtual void propagate_output_messages() + { + // Move the messages from the processedMessages queue to the internal storage + // to make them ready for propagating out + + // If there are messages in the message queue, the queue is blocked and a + // propagation should not happen unless it has been forced using resume_propagation + bool _FIsBlocked = (_M_messageBuffer._Count() > 0); + + for(;;) + { + message<_Type> * _PInputMessage = _M_processedMessages._Dequeue(); + if(_PInputMessage == NULL) + { + break; + } + _M_messageBuffer._Enqueue(_PInputMessage); + } + + if (_M_fForceRepropagation == false && _FIsBlocked == true) + { + return; + } + + // Reset the repropagation flag because a propagation has started. + _M_fForceRepropagation = false; + + // Attempt to propagate messages to all the targets + _Propagate_priority_order(_M_messageBuffer); + } + +private: + + /// <summary> + /// Propagates messages in priority order. + /// </summary> + /// <param name="_MessageBuffer"> + /// Reference to a message queue with messages to be propagated + /// </param> + /**/ + void _Propagate_priority_order(::Concurrency::details::_Queue<message<_Target_type>> & _MessageBuffer) + { + message<_Target_type> * _Msg = _MessageBuffer._Peek(); + + // If someone has reserved the _Head message, don't propagate anymore + if (_M_pReservedFor != NULL) + { + return; + } + + while (_Msg != NULL) + { + message_status _Status = declined; + + // Always start from the first target that linked + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Target_type> * _PTarget = *_Iter; + _Status = _PTarget->propagate(_Msg, this); + + // Ownership of message changed. Do not propagate this + // message to any other target. + if (_Status == accepted) + { + break; + } + + // If the target just propagated to reserved this message, stop + // propagating it to others + if (_M_pReservedFor != NULL) + { + break; + } + } + + // If status is anything other than accepted, then the head message + // was not propagated out. Thus, nothing after it in the queue can + // be propagated out. Cease propagation. + if (_Status != accepted) + { + break; + } + + // Get the next message + _Msg = _MessageBuffer._Peek(); + } + } + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Input messages for this message block are in the base-class input buffer + // All messages in that buffer are guaranteed to have moved to the output + // buffer because the destructor first waits for all async sends to finish + // before reaching this point + + // Delete any messages remaining in the output queue + for (;;) + { + message<_Type> * _Msg = _M_messageBuffer._Dequeue(); + if (_Msg == NULL) + { + break; + } + delete _Msg; + } + } + + /// <summary> + /// Message queue used to store processed messages + /// </summary> + /**/ + ::Concurrency::details::_Queue<message<_Type>> _M_processedMessages; + + /// <summary> + /// Message queue used to store messages + /// </summary> + /**/ + ::Concurrency::details::_Queue<message<_Type>> _M_messageBuffer; + + /// <summary> + /// A bool to signal to the processor to force a repropagation to occur + /// </summary> + /**/ + bool _M_fForceRepropagation; + +private: + // + // Hide assignment operator and copy constructor + // + unbounded_buffer const &operator =(unbounded_buffer const&); // no assignment operator + unbounded_buffer(unbounded_buffer const &); // no copy constructor +}; + +//************************************************************************** +// Overwrite Buffers: +//************************************************************************** + +/// <summary> +/// An <c>overwrite_buffer</c> messaging block is a multi-target, multi-source, ordered +/// <c>propagator_block</c> capable of storing a single message at +/// a time. New messages overwrite previously held ones. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the messages stored and propagated by the buffer. +/// </typeparam> +/// <remarks> +/// An <c>overwrite_buffer</c> messaging block propagates out copies of its stored message to each of its targets. +/// <para>For more information, see <see cref="Asynchronous Message Blocks"/>.</para> +/// </remarks> +/// <seealso cref="unbounded_buffer Class"/> +/// <seealso cref="single_assignment Class"/> +/**/ +template<class _Type> +class overwrite_buffer : public propagator_block<multi_link_registry<ITarget<_Type>>, multi_link_registry<ISource<_Type>>> +{ +public: + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer() : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(); + } + + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer(filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(); + register_filter(_Filter); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>overwrite_buffer</c> messaging block is scheduled. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer(Scheduler& _PScheduler) : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(&_PScheduler); + } + + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>overwrite_buffer</c> messaging block is scheduled. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer(Scheduler& _PScheduler, + filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(&_PScheduler); + register_filter(_Filter); + } + + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>overwrite_buffer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer(ScheduleGroup& _PScheduleGroup) : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs an <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>overwrite_buffer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>overwrite_buffer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + overwrite_buffer(ScheduleGroup& _PScheduleGroup, + filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL), _M_pReservedMessage(NULL) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + register_filter(_Filter); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>overwrite_buffer</c> messaging block. + /// </summary> + /**/ + ~overwrite_buffer() + { + // Remove all links that are targets of this overwrite_buffer + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + } + + /// <summary> + /// Checks whether this <c>overwrite_buffer</c> messaging block has a value yet. + /// </summary> + /// <returns> + /// <c>true</c> if the block has received a value, <c>false</c> otherwise. + /// </returns> + /**/ + bool has_value() const + { + return _M_fIsInitialized != 0; + } + + /// <summary> + /// Gets a reference to the current payload of the message being stored in the <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <returns> + /// The payload of the currently stored message. + /// </returns> + /// <remarks> + /// The value stored in the <c>overwrite_buffer</c> could change immediately after this method returns. This method will + /// wait until a message arrives if no message is currently stored in the <c>overwrite_buffer</c>. + /// </remarks> + /**/ + _Type value() + { + return receive<_Type>(this); + } + +protected: + + // + // propagator_block protected function implementation + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>overwrite_buffer</c> messaging block. + /// It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + message_status _Result = accepted; + + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + // + // If message was accepted, set the member variables for + // this block and start the asynchronous propagation task + // + if (_PMessage != NULL) + { + // Add a reference for the async_send holding the message + _PMessage->add_ref(); + + async_send(_PMessage); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Synchronously passes a message from an <c>ISource</c> block to this <c>overwrite_buffer</c> messaging block. + /// It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status send_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + // + // If message was accepted, set the member variables for + // this block and start the asynchronous propagation task + // + if (_PMessage != NULL) + { + // Add a reference for the sync_send holding the message + _PMessage->add_ref(); + + sync_send(_PMessage); + } + else + { + return missed; + } + + return accepted; + } + + /// <summary> + /// Overrides the <c>supports_anonymous_source</c> method to indicate that this block can + /// accept messages offered to it by a source that is not linked. + /// </summary> + /// <returns> + /// <c>true</c> because the block does not postpone offered messages. + /// </returns> + /**/ + virtual bool supports_anonymous_source() + { + return true; + } + + /// <summary> + /// Accepts a message that was offered by this <c>overwrite_buffer</c> messaging block, + /// returning a copy of the message to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>overwrite_buffer</c> messaging block returns copies of the message + /// to its targets, rather than transferring ownership of the currently + /// held message. + /// </remarks> + /**/ + virtual message<_Type> * accept_message(runtime_object_identity _MsgId) + { + // + // If the internal message has not yet been initialized yet, return NULL + // + if (_M_pMessage == NULL) + { + return NULL; + } + + // + // Instead of returning the internal message, we return a copy of the + // message stored. + // + // Because we are returning a copy, the accept routine for an overwritebuffer + // does not need to grab the internalLock + // + message<_Type> * _Msg = NULL; + if (_M_pMessage->msg_id() == _MsgId) + { + _Msg = new message<_Type>(_M_pMessage->payload); + } + + return _Msg; + } + + /// <summary> + /// Reserves a message previously offered by this <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // Ensure that this message currently exists in the overwrite buffer + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return false; + } + + // Can only reserve one message, any other blocks trying to reserve + // will return false + _CONCRT_ASSERT(_M_pReservedMessage == NULL); + + // Save this message away + _M_pReservedMessage = _M_pMessage; + + // Add a reference for this message to prevent deletion + _M_pReservedMessage->add_ref(); + + return true; + } + + /// <summary> + /// Consumes a message previously offered by the <c>overwrite_buffer</c> messaging block and reserved by the target, + /// returning a copy of the message to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Type> * consume_message(runtime_object_identity _MsgId) + { + // Leave and return NULL if this msgId doesn't match the reserved message + // Otherwise this is a pull of a later overwritten message, and messages + // could them appear out of order. + if (_M_pReservedMessage != NULL && _M_pReservedMessage->msg_id() != _MsgId) + { + return NULL; + } + // This redundant assert is specifically to make the /analyze switch happy, which cannot recognize the same assertion above in if stmnt. + _CONCRT_ASSERT( _M_pReservedMessage != NULL ); + + _Type _Payload = _M_pReservedMessage->payload; + + // Take the reserved message + message<_Type> * _Result = new message<_Type>(_Payload); + + if (_M_pReservedMessage->remove_ref() == 0) + { + delete _M_pReservedMessage; + } + _M_pReservedMessage = NULL; + + return _Result; + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + _CONCRT_ASSERT(_M_fIsInitialized); + _CONCRT_ASSERT(_M_pReservedMessage != NULL); + + if (_MsgId != _M_pReservedMessage->msg_id()) + { + throw message_not_found(); + } + + if (_M_pReservedMessage->remove_ref() == 0) + { + delete _M_pReservedMessage; + } + _M_pReservedMessage = NULL; + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // On reservation we do not stop propagation. So there + // is nothing to be done to resume propagation. + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>overwrite_buffer</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Type> * _PTarget) + { + // If there is a message available already, propagate it + if (_M_pMessage != NULL) + { + _PTarget->propagate(_M_pMessage, this); + } + } + + /// <summary> + /// Places the <c>message</c> <paramref name="_PMessage"/> in this <c>overwrite_buffer</c> messaging block and + /// offers it to all of the linked targets. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a <c>message</c> object that this <c>overwrite_buffer</c> has taken ownership of. + /// </param> + /// <remarks> + /// This method overwrites the current message in the <c>overwrite_buffer</c> with the newly + /// accepted message <paramref name="_PMessage"/>. + /// </remarks> + /**/ + virtual void propagate_to_any_targets(_Inout_ message<_Type> * _PMessage) + { + // Move the message from the queuedMessages Buffer to the internal storage + + // Add a reference for the overwrite_buffer holding the message + _PMessage->add_ref(); + + if (_M_pMessage != NULL) + { + if (_M_pMessage->remove_ref() == 0) + { + delete _M_pMessage; + } + } + + _M_pMessage = _PMessage; + + // Now that message has been received, set this block as initialized + _M_fIsInitialized = true; + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + // Overwrite buffers can propagate its message out + // to any number of Targets + + ITarget<_Type> * _PTarget = *_Iter; + _PTarget->propagate(_PMessage, this); + } + + if (_PMessage->remove_ref() == 0) + { + delete _PMessage; + } + } + +private: + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Input messages for this message block are in the base-class input buffer + // All messages in that buffer are guaranteed to have moved to the output + // buffer because the destructor first waits for all async sends to finish + // before reaching this point + + // The messages for an overwrite buffer are deleted when overwritten + // through reference counting. This final check is put in place in + // case any message still exists in the buffer when the overwrite_buffer + // is deleted. The reference count of this message has not yet reached + // zero because it hasn't been overwritten yet. It is safe because of + // we have finished all propagation. + if (_M_pMessage != NULL) + { + // A block can only have a reserved message after receiving a message + // at some point, so it must be within the above if-clause. + // Now delete the reserved message if it is non-NULL and different from + // the saved internal message + if (_M_pReservedMessage != NULL && _M_pReservedMessage != _M_pMessage) + { + delete _M_pReservedMessage; + } + delete _M_pMessage; + } + } + + // + // Private Data Members + // + + // The message being stored + message<_Type> * _M_pMessage; + + // The message being reserved + message<_Type> * _M_pReservedMessage; + + // The marker for whether the overwrite buffer has already been initialized + volatile bool _M_fIsInitialized; + +private: + // + // Hide assignment operator and copy constructor + // + overwrite_buffer const &operator =(overwrite_buffer const&); // no assignment operator + overwrite_buffer(overwrite_buffer const &); // no copy constructor +}; + +//************************************************************************** +// Call: +//************************************************************************** + +/// <summary> +/// A <c>call</c> messaging block is a multi-source, ordered <c>target_block</c> that +/// invokes a specified function when receiving a message. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the messages propagated to this block. +/// </typeparam> +/// <typeparam name="_FunctorType"> +/// The signature of functions that this block can accept. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="transformer Class"/> +/**/ +template<class _Type, class _FunctorType = std::tr1::function<void(_Type const&)>> +class call : public target_block<multi_link_registry<ISource<_Type>>> +{ + /// <summary> + /// The function type that this block executes upon receiving a <c>message</c>. + /// </summary> + /**/ + typedef _FunctorType _Call_method; + +public: + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(_Call_method const& _Func) : + _M_pFunc(_Func) + { + initialize_target(); + enable_batched_processing(); + } + + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(_Call_method const& _Func, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_target(); + enable_batched_processing(); + register_filter(_Filter); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>call</c> messaging block is scheduled. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(Scheduler& _PScheduler, + _Call_method const& _Func) : + _M_pFunc(_Func) + { + initialize_target(&_PScheduler); + enable_batched_processing(); + } + + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>call</c> messaging block is scheduled. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(Scheduler& _PScheduler, + _Call_method const& _Func, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_target(&_PScheduler); + enable_batched_processing(); + register_filter(_Filter); + } + + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>call</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(ScheduleGroup& _PScheduleGroup, + _Call_method const& _Func) : + _M_pFunc(_Func) + { + initialize_target(NULL, &_PScheduleGroup); + enable_batched_processing(); + } + + /// <summary> + /// Constructs a <c>call</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>call</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Call_method"/> is a functor with signature <c>void (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>call</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + call(ScheduleGroup& _PScheduleGroup, + _Call_method const& _Func, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_target(NULL, &_PScheduleGroup); + enable_batched_processing(); + register_filter(_Filter); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>call</c> messaging block. + /// </summary> + /**/ + ~call() + { + remove_sources(); + } + +protected: + + // + // target_block protected function implementations + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>call</c> messaging block. It is invoked + /// by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + message_status _Result = accepted; + + // + // Accept the message being propagated + // Note: depending on the source block propagating the message + // this may not necessarily be the same message (pMessage) first + // passed into the function. + // + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + async_send(_PMessage); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Synchronously passes a message from an <c>ISource</c> block to this <c>call</c> messaging block. It is invoked + /// by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status send_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + message_status _Result = accepted; + + // + // Accept the message being propagated + // Note: depending on the source block propagating the message + // this may not necessarily be the same message (pMessage) first + // passed into the function. + // + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + sync_send(_PMessage); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Overrides the <c>supports_anonymous_source</c> method to indicate that this block can + /// accept messages offered to it by a source that is not linked. + /// </summary> + /// <returns> + /// <c>true</c> because the block does not postpone offered messages. + /// </returns> + /**/ + virtual bool supports_anonymous_source() + { + return true; + } + + /// <summary> + /// Processes a message that was accepted by this <c>call</c> messaging block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the message that is to be handled. + /// </param> + /**/ + virtual void process_message(_Inout_ message<_Type> * _PMessage) + { + // No longer necessary with CRT110 change + } + + /// <summary> + /// Executes the call function on the input messages. + /// </summary> + /**/ + virtual void process_input_messages(_Inout_ message<_Type> * _PMessage) + { + // Invoke the function provided by the user + _CONCRT_ASSERT(_PMessage != NULL); + _M_pFunc(_PMessage->payload); + delete _PMessage; + } + +private: + + // + // Private Data Members + // + + // The call method called by this block + _Call_method _M_pFunc; + +private: + // + // Hide assignment operator and copy constructor + // + call const &operator =(call const&); // no assignment operator + call(call const &); // no copy constructor +}; + +//************************************************************************** +// Transformer: +//************************************************************************** + +/// <summary> +/// A <c>transformer</c> messaging block is a single-target, multi-source, ordered +/// <c>propagator_block</c> which can accept messages of one type and is +/// capable of storing an unbounded number of messages of a different type. +/// </summary> +/// <typeparam name="_Input"> +/// The payload type of the messages accepted by the buffer. +/// </typeparam> +/// <typeparam name="_Output"> +/// The payload type of the messages stored and propagated out by the buffer. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="call Class"/> +/**/ +template<class _Input, class _Output> +class transformer : public propagator_block<single_link_registry<ITarget<_Output>>, multi_link_registry<ISource<_Input>>> +{ + typedef std::tr1::function<_Output(_Input const&)> _Transform_method; + +public: + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transformer. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(_Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget = NULL) : + _M_pFunc(_Func) + { + initialize_source_and_target(); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transform. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(_Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_source_and_target(); + register_filter(_Filter); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>transformer</c> messaging block is scheduled. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transformer. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(Scheduler& _PScheduler, + _Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget = NULL) : + _M_pFunc(_Func) + { + initialize_source_and_target(&_PScheduler); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>transformer</c> messaging block is scheduled. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transformer. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(Scheduler& _PScheduler, + _Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_source_and_target(&_PScheduler); + register_filter(_Filter); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>transformer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transformer. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(ScheduleGroup& _PScheduleGroup, + _Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget = NULL) : + _M_pFunc(_Func) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + + /// <summary> + /// Constructs a <c>transformer</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>transformer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Func"> + /// A function that will be invoked for each accepted message. + /// </param> + /// <param name="_PTarget"> + /// A pointer to a target block to link with the transformer. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="_Transform_method"/> is a functor with signature <c>_Output (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to process a message.</para> + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Input const &)</c> + /// which is invoked by this <c>transformer</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + transformer(ScheduleGroup& _PScheduleGroup, + _Transform_method const& _Func, + _Inout_opt_ ITarget<_Output> * _PTarget, + filter_method const& _Filter) : + _M_pFunc(_Func) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + register_filter(_Filter); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>transformer</c> messaging block. + /// </summary> + /**/ + ~transformer() + { + // Remove all links + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + } + +protected: + + // Propagator_block protected function implementations + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>transformer</c> messaging block. + /// It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Input> * _PMessage, _Inout_ ISource<_Input> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + message_status _Result = accepted; + + // + // Accept the message being propagated + // Note: depending on the source block propagating the message + // this may not necessarily be the same message (pMessage) first + // passed into the function. + // + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + // Enqueue the input message + _M_inputMessages.push(_PMessage); + async_send(NULL); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Synchronously passes a message from an <c>ISource</c> block to this <c>transformer</c> messaging block. + /// It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status send_message(_Inout_ message<_Input> * _PMessage, _Inout_ ISource<_Input> * _PSource) + { + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_PMessage != NULL) + { + // Enqueue the input message + _M_inputMessages.push(_PMessage); + sync_send(NULL); + } + else + { + return missed; + } + + return accepted; + } + + /// <summary> + /// Overrides the <c>supports_anonymous_source</c> method to indicate that this block can + /// accept messages offered to it by a source that is not linked. + /// </summary> + /// <returns> + /// <c>true</c> because the block does not postpone offered messages. + /// </returns> + /**/ + virtual bool supports_anonymous_source() + { + return true; + } + + /// <summary> + /// Accepts a message that was offered by this <c>transformer</c> messaging block, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_Output> * accept_message(runtime_object_identity _MsgId) + { + // + // Peek at the head message in the message buffer. If the IDs match + // dequeue and transfer ownership + // + message<_Output> * _Msg = NULL; + + if (_M_messageBuffer._Is_head(_MsgId)) + { + _Msg = _M_messageBuffer._Dequeue(); + } + + return _Msg; + } + + /// <summary> + /// Reserves a message previously offered by this <c>transformer</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // Allow reservation if this is the head message + return _M_messageBuffer._Is_head(_MsgId); + } + + /// <summary> + /// Consumes a message previously offered by the <c>transformer</c> and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Output> * consume_message(runtime_object_identity _MsgId) + { + // By default, accept the message + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + // The head message is the one reserved. + if (!_M_messageBuffer._Is_head(_MsgId)) + { + throw message_not_found(); + } + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // If there are any messages in the buffer, propagate them out + if (_M_messageBuffer._Count() > 0) + { + // async send a NULL value to initiate the repropagation + async_send(NULL); + } + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>transformer</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Output> *) + { + // If the message queue is blocked due to reservation + // there is no need to do any message propagation + if (_M_pReservedFor != NULL) + { + return; + } + + _Propagate_priority_order(_M_messageBuffer); + } + + /// <summary> + /// Executes the transformer function on the input messages. + /// </summary> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<_Output> *) + { + message<_Output> * _Msg = NULL; + + // Process input message. + message<_Input> * _PInputMessage = NULL; + _M_inputMessages.try_pop(_PInputMessage); + + if (_PInputMessage != NULL) + { + // Invoke the TransformMethod on the data + // Let exceptions flow + _Output _Out = _M_pFunc(_PInputMessage->payload); + + // Reuse the input message ID + _Msg = new message<_Output>(_Out, _PInputMessage->msg_id()); + _M_messageBuffer._Enqueue(_Msg); + + // Message cleanup + delete _PInputMessage; + + if (!_M_messageBuffer._Is_head(_Msg->msg_id())) + { + return; + } + } + + _Propagate_priority_order(_M_messageBuffer); + } + +private: + + /// <summary> + /// Propagates messages in priority order. + /// </summary> + /// <param name="_MessageBuffer"> + /// Reference to a message queue with messages to be propagated + /// </param> + /**/ + void _Propagate_priority_order(::Concurrency::details::_Queue<message<_Target_type>> & _MessageBuffer) + { + message<_Target_type> * _Msg = _MessageBuffer._Peek(); + + // If someone has reserved the _Head message, don't propagate anymore + if (_M_pReservedFor != NULL) + { + return; + } + + while (_Msg != NULL) + { + message_status _Status = declined; + + // Always start from the first target that linked + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Target_type> * _PTarget = *_Iter; + _Status = _PTarget->propagate(_Msg, this); + + // Ownership of message changed. Do not propagate this + // message to any other target. + if (_Status == accepted) + { + break; + } + + // If the target just propagated to reserved this message, stop + // propagating it to others + if (_M_pReservedFor != NULL) + { + break; + } + } + + // If status is anything other than accepted, then the head message + // was not propagated out. Thus, nothing after it in the queue can + // be propagated out. Cease propagation. + if (_Status != accepted) + { + break; + } + + // Get the next message + _Msg = _MessageBuffer._Peek(); + } + } + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Delete input messages + // Because the transformer uses its own input queue, it's possible there are messages + // in this queue and no LWT will be executed to handle them. + message<_Input> * _PInputQueueMessage = NULL; + + while (_M_inputMessages.try_pop(_PInputQueueMessage)) + { + // Message cleanup + delete _PInputQueueMessage; + } + + // Delete any messages remaining in the output queue + for (;;) + { + message<_Output> * _Msg = _M_messageBuffer._Dequeue(); + if (_Msg == NULL) + { + break; + } + delete _Msg; + } + } + + // + // Private Data Members + // + + // The transformer method called by this block + _Transform_method _M_pFunc; + + // The queue of input messages for this Transformer block + concurrent_queue<message<_Input> *> _M_inputMessages; + + /// <summary> + /// Message queue used to store outbound messages + /// </summary> + /**/ + ::Concurrency::details::_Queue<message<_Output>> _M_messageBuffer; + +private: + // + // Hide assignment operator and copy constructor + // + transformer const &operator =(transformer const &); // no assignment operator + transformer(transformer const &); // no copy constructor +}; + +//************************************************************************** +// Timer: +//************************************************************************** +/// <summary> +/// A <c>timer</c> messaging block is a single-target <c>source_block</c> capable of sending +/// a message to its target after a specified time period has elapsed +/// or at specific intervals. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the output messages of this block. +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/**/ +template<class _Type> +class timer : public Concurrency::details::_Timer, public source_block<single_link_registry<ITarget<_Type>>> +{ +private: + + /// <summary> + /// Tracks the state machine of the timer. + /// </summary> + /**/ + enum State + { + /// <summary> + /// The timer has been initialized, but not yet started. + /// </summary> + /**/ + Initialized, + /// <summary> + /// The timer has been started. + /// </summary> + /**/ + Started, + /// <summary> + /// The timer has started and been paused. + /// </summary> + /**/ + Paused, + /// <summary> + /// The timer has been stopped. + /// </summary> + /**/ + Stopped + }; + +public: + + /// <summary> + /// Constructs a <c>timer</c> messaging block that will fire a given message after a specified interval. + /// </summary> + /// <param name="_Ms"> + /// The number of milliseconds that must elapse after the call to start for the specified message + /// to be propagated downstream. + /// </param> + /// <param name="_Value"> + /// The value which will be propagated downstream when the timer elapses. + /// </param> + /// <param name="_PTarget"> + /// The target to which the timer will propagate its message. + /// </param> + /// <param name="_Repeating"> + /// If true, indicates that the timer will fire periodically every <paramref name="_Ms"/> milliseconds. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_Scheduler"/> + /// or <paramref name="_ScheduleGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + timer(unsigned int _Ms, _Type const& _Value, ITarget<_Type> *_PTarget = NULL, bool _Repeating = false) : + _Timer(_Ms, _Repeating) + { + _Initialize(_Value, _PTarget, _Repeating); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>timer</c> messaging block that will fire a given message after a specified interval. + /// </summary> + /// <param name="_Scheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>timer</c> messaging block is scheduled is scheduled. + /// </param> + /// <param name="_Ms"> + /// The number of milliseconds that must elapse after the call to start for the specified message + /// to be propagated downstream. + /// </param> + /// <param name="_Value"> + /// The value which will be propagated downstream when the timer elapses. + /// </param> + /// <param name="_PTarget"> + /// The target to which the timer will propagate its message. + /// </param> + /// <param name="_Repeating"> + /// If true, indicates that the timer will fire periodically every <paramref name="_Ms"/> milliseconds. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_Scheduler"/> + /// or <paramref name="_ScheduleGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + timer(Scheduler& _Scheduler, unsigned int _Ms, _Type const& _Value, _Inout_opt_ ITarget<_Type> *_PTarget = NULL, bool _Repeating = false) : + _Timer(_Ms, _Repeating) + { + _Initialize(_Value, _PTarget, _Repeating, &_Scheduler); + } + + /// <summary> + /// Constructs a <c>timer</c> messaging block that will fire a given message after a specified interval. + /// </summary> + /// <param name="_ScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>timer</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Ms"> + /// The number of milliseconds that must elapse after the call to start for the specified message + /// to be propagated downstream. + /// </param> + /// <param name="_Value"> + /// The value which will be propagated downstream when the timer elapses. + /// </param> + /// <param name="_PTarget"> + /// The target to which the timer will propagate its message. + /// </param> + /// <param name="_Repeating"> + /// If true, indicates that the timer will fire periodically every <paramref name="_Ms"/> milliseconds. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_Scheduler"/> + /// or <paramref name="_ScheduleGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + timer(ScheduleGroup& _ScheduleGroup, unsigned int _Ms, _Type const& _Value, _Inout_opt_ ITarget<_Type> *_PTarget = NULL, bool _Repeating = false) : + _Timer(_Ms, _Repeating) + { + _Initialize(_Value, _PTarget, _Repeating, NULL, &_ScheduleGroup); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys a <c>timer</c> messaging block. + /// </summary> + /**/ + ~timer() + { + // + // Make sure there are no more outstanding timer fires. Note that this does not mean that the LWT that was queued is finished, it only + // means that no more timers will fire after the return from _Stop. We still *MUST* wait on any outstanding LWTs. + // + if (_M_state == Started) + _Stop(); + + // Remove all the targets. This will wait for any outstanding LWTs + remove_targets(); + + // + // No more asynchronous operations can happen as of this point. + // + + // Clean up any messages left in this message block + _Delete_stored_messages(); + + if (_M_fReferencedScheduler) + { + ::Concurrency::details::_Scheduler(_M_pScheduler)._Release(); + } + } + + /// <summary> + /// Starts the <c>timer</c> messaging block. The specified number of milliseconds after this is called, the specified value will be propagated + /// downstream as a <c>message</c>. + /// </summary> + /**/ + void start() + { + if (_M_state == Initialized || _M_state == Paused) + { + _M_state = Started; + _Start(); + } + } + + /// <summary> + /// Stops the <c>timer</c> messaging block. + /// </summary> + /**/ + void stop() + { + if (_M_state == Started) + _Stop(); + + _M_state = Stopped; + } + + /// <summary> + /// Stops the <c>timer</c> messaging block. If it is a repeating <c>timer</c> messaging block, it can be restarted with a subsequent + /// <c>start()</c> call. For non-repeating timers, this has the same effect as a <c>stop</c> call. + /// </summary> + /**/ + void pause() + { + // + // Non repeating timers cannot pause. They go to a final stopped state on pause. + // + if (!_M_fRepeating) + { + stop(); + } + else + { + // Pause only a started timer. + + if (_M_state == Started) + { + _Stop(); + _M_state = Paused; + } + } + } + +protected: + + /// <summary> + /// Accepts a message that was offered by this <c>timer</c> messaging block, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_Type> * accept_message(runtime_object_identity _MsgId) + { + if (_M_pMessage == NULL || _MsgId != _M_pMessage->msg_id()) + { + return NULL; + } + + message<_Type> *_PMessage = _M_pMessage; + _M_pMessage = NULL; + + return _PMessage; + } + + /// <summary> + /// Reserves a message previously offered by this <c>timer</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // + // Semantically, every timer tick is the same value -- it doesn't matter the message ID. Because we can only + // have one target as well, we do not need to track anything here. + // + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return false; + } + + return true; + } + + /// <summary> + /// Consumes a message previously offered by the <c>timer</c> and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Type> * consume_message(runtime_object_identity _MsgId) + { + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + throw message_not_found(); + } + + delete _M_pMessage; + _M_pMessage = NULL; + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // Because reservation doesn't prevent propagation there is + // no need to resume on consume/release. + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>timer</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Type> * _PTarget) + { + // If there is a timer message sitting around, it must be propagated to the target now. + + if (_M_pMessage != NULL) + { + _PTarget->propagate(_M_pMessage, this); + } + } + + /// <summary> + /// Tries to offer the message produced by the <c>timer</c> block to all of the linked targets. + /// </summary> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<_Type> *) + { + if (_M_pMessage == NULL) + { + _M_pMessage = _NewMessage(); + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Type> * _PTarget = *_Iter; + _PTarget->propagate(_M_pMessage, this); + } + } + } + +private: + + // The timer message we contain + message<_Type> *_M_pMessage; + + // Current state of the timer. + State _M_state; + + // The value to send on elapse of the timer. + _Type _M_value; + + // An indication of whether the timer is repeating. + bool _M_fRepeating; + + // A flag for whether we need to release a reference on the scheduler. + bool _M_fReferencedScheduler; + + // Scheduler used for the timer + Scheduler * _M_pScheduler; + + /// <summary> + /// Allocates a new message. + /// </summary> + /**/ + message<_Type>* _NewMessage() const + { + return new message<_Type>(_M_value); + } + + /// <summary> + /// Called when the timer fires. + /// </summary> + /**/ + virtual void _Fire() + { + async_send(NULL); + } + + /// <summary> + /// Common initialization. + /// </summary> + /// <param name="_Value"> + /// The value which will be propagated downstream when the timer elapses. + /// </param> + /// <param name="_PTarget"> + /// The target to which the timer will propagate its message. + /// </param> + /// <param name="_Repeating"> + /// If true, indicates that the timer will fire periodically every _Ms milliseconds. + /// </param> + /**/ + void _Initialize(const _Type& _Value, _Inout_ ITarget<_Type> *_PTarget, bool _Repeating, _Inout_opt_ Scheduler * _PScheduler = NULL, _Inout_opt_ ScheduleGroup * _PScheduleGroup = NULL) + { + _M_pMessage = NULL; + _M_value = _Value; + _M_fRepeating = _Repeating; + _M_state = Initialized; + _M_fReferencedScheduler = false; + + // + // If we are going to utilize the current scheduler for timer firing, we need to capture it now. Otherwise, + // the timer threads fired from Windows (what _Fire executes within) will wind up with a default scheduler + // attached -- probably not the semantic we want. + // + if (_PScheduleGroup == NULL && _PScheduler == NULL) + { + ::Concurrency::details::_Scheduler _sched = ::Concurrency::details::_CurrentScheduler::_Get(); + _PScheduler = _sched._GetScheduler(); + _sched._Reference(); + _M_fReferencedScheduler = true; + } + + _M_pScheduler = _PScheduler; + initialize_source(_PScheduler, _PScheduleGroup); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + } + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Input messages for this message block are in the base-class input buffer + // All messages in that buffer are guaranteed to have moved to the output + // buffer because the destructor first waits for all async sends to finish + // before reaching this point + + // Delete the message remaining in the output queue + if (_M_pMessage != NULL) + { + delete _M_pMessage; + } + } + +private: + // + // Hide assignment operator and copy constructor + // + timer const &operator =(timer const &); // no assignment operator + timer(timer const &); // no copy constructor +}; + +//************************************************************************** +// Single assignment: +//************************************************************************** + +/// <summary> +/// A <c>single_assignment</c> messaging block is a multi-target, multi-source, ordered +/// <c>propagator_block</c> capable of storing a single, write-once +/// <c>message</c>. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the message stored and propagated by the buffer. +/// </typeparam> +/// <remarks> +/// A <c>single_assignment</c> messaging block propagates out copies of its message to each target. +/// <para>For more information, see <see cref="Asynchronous Message Blocks"/>.</para> +/// </remarks> +/// <seealso cref="overwrite_buffer Class"/> +/// <seealso cref="unbounded_buffer Class"/> +/**/ +template<class _Type> +class single_assignment : public propagator_block<multi_link_registry<ITarget<_Type>>, multi_link_registry<ISource<_Type>>> +{ +public: + + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment() : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(); + } + + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment(filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(); + register_filter(_Filter); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>single_assignment</c> messaging block is scheduled. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment(Scheduler& _PScheduler) : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(&_PScheduler); + } + + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>single_assignment</c> messaging block is scheduled. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment(Scheduler& _PScheduler, filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(&_PScheduler); + register_filter(_Filter); + } + + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>single_assignment</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment(ScheduleGroup& _PScheduleGroup) : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs a <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>single_assignment</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>single_assignment</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + single_assignment(ScheduleGroup& _PScheduleGroup, filter_method const& _Filter) : + _M_fIsInitialized(false), _M_pMessage(NULL) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + register_filter(_Filter); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>single_assignment</c> messaging block. + /// </summary> + /**/ + ~single_assignment() + { + // Remove all links + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + } + + /// <summary> + /// Checks whether this <c>single_assignment</c> messaging block has been initialized with a value yet. + /// </summary> + /// <returns> + /// <c>true</c> if the block has received a value, <c>false</c> otherwise. + /// </returns> + /**/ + bool has_value() const + { + return (_M_pMessage != NULL); + } + + + /// <summary> + /// Gets a reference to the current payload of the message being stored in the <c>single_assignment</c> messaging block. + /// </summary> + /// <returns> + /// The payload of the stored message. + /// </returns> + /// <remarks> + /// This method will wait until a message arrives if no message is currently stored in the <c>single_assignment</c> messaging block. + /// </remarks> + /**/ + _Type const & value() + { + if (_M_pMessage == NULL) + { + receive<_Type>(this); + } + _CONCRT_ASSERT(_M_pMessage != NULL); + + return _M_pMessage->payload; + } + + +protected: + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>single_assignment</c> messaging block. + /// It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + message_status _Result = accepted; + + // single_assignment messaging block can be initialized only once + if (_M_fIsInitialized) + { + return declined; + } + + { + _NR_lock _Lock(_M_propagationLock); + + if (_M_fIsInitialized) + { + _Result = declined; + } + else + { + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + // Set initialized flag only if we have a message + if (_PMessage != NULL) + { + _M_fIsInitialized = true; + } + else + { + _Result = missed; + } + } + } + + // + // If message was accepted, set the member variables for + // this block and start the asynchronous propagation task + // + if (_Result == accepted) + { + async_send(_PMessage); + } + + return _Result; + } + + /// <summary> + /// Synchronously passes a message from an <c>ISource</c> block to this <c>single_assignment</c> messaging block. + /// It is invoked by the <c>send</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status send_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + message_status _Result = accepted; + + // single_assignment messaging block can be initialized only once + if (_M_fIsInitialized) + { + return declined; + } + + { + _NR_lock _Lock(_M_propagationLock); + + if (_M_fIsInitialized) + { + _Result = declined; + } + else + { + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + // Set initialized flag only if we have a message + if (_PMessage != NULL) + { + _M_fIsInitialized = true; + } + else + { + _Result = missed; + } + } + } + + // + // If message was accepted, set the member variables for + // this block and start the asynchronous propagation task + // + if (_Result == accepted) + { + sync_send(_PMessage); + } + + return _Result; + } + + /// <summary> + /// Accepts a message that was offered by this <c>single_assignment</c> messaging block, + /// returning a copy of the message to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>single_assignment</c> messaging block returns copies of the message + /// to its targets, rather than transferring ownership of the currently + /// held message. + /// </remarks> + /**/ + virtual message<_Type> * accept_message(runtime_object_identity _MsgId) + { + // This check is to prevent spoofing and verify that the propagated message is + // the one that is accepted at the end. + if (_M_pMessage == NULL || _MsgId != _M_pMessage->msg_id()) + { + return NULL; + } + + // + // Instead of returning the internal message, we return a copy of the + // message passed in. + // + // Because we are returning a copy, the accept routine for a single_assignment + // does not need to grab the internal lock. + // + return (new message<_Type>(_M_pMessage->payload)); + } + + /// <summary> + /// Reserves a message previously offered by this <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + if (_M_pMessage == NULL) + { + return false; + } + + if (_M_pMessage->msg_id() != _MsgId) + { + throw message_not_found(); + } + + return true; + } + + /// <summary> + /// Consumes a message previously offered by the <c>single_assignment</c> and reserved by the target, + /// returning a copy of the message to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Type> * consume_message(runtime_object_identity _MsgId) + { + _CONCRT_ASSERT(_M_fIsInitialized); + + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + _CONCRT_ASSERT(_M_fIsInitialized); + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + throw message_not_found(); + } + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // Because reservation doesn't stop propagation, we don't + // need to do anything on resume after consume/release. + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>single_assignment</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Type> * _PTarget) + { + // If there is a message available already, propagate it. + + if (_M_pMessage != NULL) + { + _PTarget->propagate(_M_pMessage, this); + } + } + /// <summary> + /// Places the <c>message</c> <paramref name="_PMessage"/> in this <c>single_assignment</c> messaging block and + /// offers it to all of the linked targets. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a <c>message</c> that this <c>single_assignment</c> messaging block has taken ownership of. + /// </param> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<_Type> * _PMessage) + { + // Initialized flag should have been set by the propagate function using interlocked operation. + _CONCRT_ASSERT(_M_fIsInitialized); + + // Move the message to the internal storage + + _CONCRT_ASSERT(_M_pMessage == NULL); + _M_pMessage = _PMessage; + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + // Single assignment can propagate its message out + // to any number of Targets + + ITarget<_Type> * _PTarget = *_Iter; + _PTarget->propagate(_PMessage, this); + } + } + +private: + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Input messages for this message block are in the base-class input buffer + // All messages in that buffer are guaranteed to have moved to the output + // buffer because the destructor first waits for all async sends to finish + // before reaching this point + + // The messages for a single_assignment are deleted at the end when + // single_assignment is deleted. + delete _M_pMessage; + } + + // + // Private Data Members + // + + // The message being stored + message<_Type> * _M_pMessage; + + // The lock used to protect propagation + ::Concurrency::details::_NonReentrantPPLLock _M_propagationLock; + + // The marker for whether the single_assignment has already been initialized + volatile bool _M_fIsInitialized; + +private: + // + // Hide assignment operator and copy constructor + // + single_assignment const & operator=(single_assignment const &); // no assignment operator + single_assignment(single_assignment const &); // no copy constructor +}; + +//************************************************************************** +// Join (single-type) +//************************************************************************** + +/// <summary> +/// The type of a <c>join</c> messaging block. +/// </summary> +/**/ +enum join_type { + /// <summary> + /// Greedy <c>join</c> messaging blocks immediately accept a message upon propagation. This is more efficient, + /// but has the possibility for live-lock, depending on the network configuration. + /// </summary> + /**/ + greedy = 0, + /// <summary> + /// Non-greedy <c>join</c> messaging blocks postpone messages and try and consume them after all have arrived. + /// These are guaranteed to work, but slower. + /// </summary> + /**/ + non_greedy = 1 +}; + +/// <summary> +/// A <c>join</c> messaging block is a single-target, multi-source, ordered +/// <c>propagator_block</c> which combines together messages of type <typeparamref name="_Type"/> from each +/// of its sources. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type of the messages joined and propagated by the block. +/// </typeparam> +/// <typeparam name="_Jtype"> +/// The kind of <c>join</c> block this is, either <c>greedy</c> or <c>non_greedy</c> +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="choice Class"/> +/// <seealso cref="multitype_join Class"/> +/// <seealso cref="join_type Enumeration"/> +/**/ +template<class _Type, join_type _Jtype = non_greedy> +class join : public propagator_block<single_link_registry<ITarget<std::vector<_Type>>>, multi_link_registry<ISource<_Type>>> +{ +public: + typedef typename std::vector<_Type> _OutputType; + + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(size_t _NumInputs) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs); + } + + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(size_t _NumInputs, filter_method const& _Filter) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs); + register_filter(_Filter); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>join</c> messaging block is scheduled. + /// </param> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(Scheduler& _PScheduler, size_t _NumInputs) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs, &_PScheduler); + } + + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>join</c> messaging block is scheduled. + /// </param> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(Scheduler& _PScheduler, size_t _NumInputs, filter_method const& _Filter) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs, &_PScheduler); + register_filter(_Filter); + } + + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>join</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(ScheduleGroup& _PScheduleGroup, size_t _NumInputs) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs a <c>join</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>join</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_NumInputs"> + /// The number of inputs this <c>join</c> block will be allowed. + /// </param> + /// <param name="_Filter"> + /// A filter function which determines whether offered messages should be accepted. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// <para>The type <typeparamref name="filter_method"/> is a functor with signature <c>bool (_Type const &)</c> + /// which is invoked by this <c>join</c> messaging block to determine whether or not it should accept + /// an offered message.</para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + join(ScheduleGroup& _PScheduleGroup, size_t _NumInputs, filter_method const& _Filter) + : _M_messageArray(_NumInputs), + _M_savedMessageIdArray(_NumInputs) + { + _Initialize(_NumInputs, NULL, &_PScheduleGroup); + register_filter(_Filter); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the <c>join</c> block. + /// </summary> + /**/ + ~join() + { + // Remove all links that are targets of this join + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + + delete [] _M_savedIdBuffer; + } + +protected: + // + // propagator_block protected function implementations + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>join</c> messaging block. + /// It is invoked by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + message_status propagate_message(_Inout_ message<_Type> * _PMessage, _Inout_ ISource<_Type> * _PSource) + { + // It is important that calls to propagate do *not* take the same lock on the + // internal structure that is used by Consume and the LWT. Doing so could + // result in a deadlock with the Consume call. + + message_status _Ret_val = accepted; + + // + // Find the slot index of this source + // + size_t _Slot = 0; + bool _Found = false; + for (source_iterator _Iter = _M_connectedSources.begin(); *_Iter != NULL; ++_Iter) + { + if (*_Iter == _PSource) + { + _Found = true; + break; + } + + _Slot++; + } + + if (!_Found) + { + // If this source was not found in the array, this is not a connected source + // decline the message + return declined; + } + + _CONCRT_ASSERT(_Slot < _M_messageArray._M_count); + + bool fIsGreedy = (_Jtype == greedy); + + if (fIsGreedy) + { + // + // Greedy type joins immediately accept the message. + // + { + _NR_lock lockHolder(_M_propagationLock); + if (_M_messageArray._M_messages[_Slot] != NULL) + { + _M_savedMessageIdArray._M_savedIds[_Slot] = _PMessage->msg_id(); + _Ret_val = postponed; + } + } + + if (_Ret_val != postponed) + { + _M_messageArray._M_messages[_Slot] = _PSource->accept(_PMessage->msg_id(), this); + + if (_M_messageArray._M_messages[_Slot] != NULL) + { + if (_InterlockedDecrementSizeT(&_M_messagesRemaining) == 0) + { + // If messages have arrived on all links, start a propagation + // of the current message + async_send(NULL); + } + } + else + { + _Ret_val = missed; + } + } + } + else + { + // + // Non-greedy type joins save the message IDs until they have all arrived + // + + if (_InterlockedExchange((volatile long *) &_M_savedMessageIdArray._M_savedIds[_Slot], _PMessage->msg_id()) == -1) + { + // Decrement the message remaining count if this thread is switching + // the saved ID from -1 to a valid value. + if (_InterlockedDecrementSizeT(&_M_messagesRemaining) == 0) + { + async_send(NULL); + } + } + + // Always return postponed. This message will be consumed + // in the LWT + _Ret_val = postponed; + } + + return _Ret_val; + } + + /// <summary> + /// Accepts a message that was offered by this <c>join</c> messaging block, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_OutputType> * accept_message(runtime_object_identity _MsgId) + { + // + // Peek at the head message in the message buffer. If the IDs match + // dequeue and transfer ownership + // + message<_OutputType> * _Msg = NULL; + + if (_M_messageBuffer._Is_head(_MsgId)) + { + _Msg = _M_messageBuffer._Dequeue(); + } + + return _Msg; + } + + /// <summary> + /// Reserves a message previously offered by this <c>join</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // Allow reservation if this is the head message + return _M_messageBuffer._Is_head(_MsgId); + } + + /// <summary> + /// Consumes a message previously offered by the <c>join</c> messaging block and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being consumed. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_OutputType> * consume_message(runtime_object_identity _MsgId) + { + // By default, accept the message + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + // The head message is the one reserved. + if (!_M_messageBuffer._Is_head(_MsgId)) + { + throw message_not_found(); + } + } + + /// <summary> + /// Resumes propagation after a reservation has been released. + /// </summary> + /**/ + virtual void resume_propagation() + { + // If there are any messages in the buffer, propagate them out + if (_M_messageBuffer._Count() > 0) + { + async_send(NULL); + } + } + + /// <summary> + /// A callback that notifies that a new target has been linked to this <c>join</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<std::vector<_Type>> *) + { + // If the message queue is blocked due to reservation + // there is no need to do any message propagation + if (_M_pReservedFor != NULL) + { + return; + } + + _Propagate_priority_order(_M_messageBuffer); + } + + /// <summary> + /// Constructs an output message containing an input message from each source when + /// they have all propagated a message. Sends this output message out to each of + /// its targets. + /// </summary> + /**/ + void propagate_to_any_targets(_Inout_opt_ message<_OutputType> *) + { + message<_OutputType> * _Msg = NULL; + // Create a new message from the input sources + // If messagesRemaining == 0, we have a new message to create. Otherwise, this is coming from + // a consume or release from the target. In that case we don't want to create a new message. + if (_M_messagesRemaining == 0) + { + // A greedy join can immediately create the message, a non-greedy + // join must try and consume all the messages it has postponed + _Msg = _Create_new_message(); + } + + if (_Msg == NULL) + { + // Create message failed. This happens in non_greedy joins when the + // reserve/consumption of a postponed message failed. + _Propagate_priority_order(_M_messageBuffer); + return; + } + + bool fIsGreedy = (_Jtype == greedy); + + // For a greedy join, reset the number of messages remaining + // Check to see if multiple messages have been passed in on any of the links, + // and postponed. If so, try and reserve/consume them now + if (fIsGreedy) + { + // Look at the saved IDs and reserve/consume any that have passed in while + // this join was waiting to complete + _CONCRT_ASSERT(_M_messageArray._M_count == _M_savedMessageIdArray._M_count); + + for (size_t i = 0; i < _M_messageArray._M_count; i++) + { + for(;;) + { + runtime_object_identity _Saved_id; + // Grab the current saved ID value. This value could be changing from based on any + // calls of source->propagate(this). If the message ID is different than what is snapped + // here, that means, the reserve below must fail. This is because reserve is trying + // to get the same source lock the propagate(this) call must be holding. + { + _NR_lock lockHolder(_M_propagationLock); + + _CONCRT_ASSERT(_M_messageArray._M_messages[i] != NULL); + + _Saved_id = _M_savedMessageIdArray._M_savedIds[i]; + + if (_Saved_id == -1) + { + _M_messageArray._M_messages[i] = NULL; + break; + } + else + { + _M_savedMessageIdArray._M_savedIds[i] = -1; + } + } + + if (_Saved_id != -1) + { + source_iterator _Iter = _M_connectedSources.begin(); + + ISource<_Type> * _PSource = _Iter[i]; + if ((_PSource != NULL) && _PSource->reserve(_Saved_id, this)) + { + _M_messageArray._M_messages[i] = _PSource->consume(_Saved_id, this); + _InterlockedDecrementSizeT(&_M_messagesRemaining); + break; + } + } + } + } + + // If messages have all been received, async_send again, this will start the + // LWT up to create a new message + if (_M_messagesRemaining == 0) + { + async_send(NULL); + } + } + + // Add the new message to the outbound queue + _M_messageBuffer._Enqueue(_Msg); + + if (!_M_messageBuffer._Is_head(_Msg->msg_id())) + { + // another message is at the head of the outbound message queue and blocked + // simply return + return; + } + + _Propagate_priority_order(_M_messageBuffer); + } + +private: + + // + // Private Methods + // + + /// <summary> + /// Propagate messages in priority order. + /// </summary> + /// <param name="_MessageBuffer"> + /// Reference to a message queue with messages to be propagated + /// </param> + /**/ + void _Propagate_priority_order(::Concurrency::details::_Queue<message<_Target_type>> & _MessageBuffer) + { + message<_Target_type> * _Msg = _MessageBuffer._Peek(); + + // If someone has reserved the _Head message, don't propagate anymore + if (_M_pReservedFor != NULL) + { + return; + } + + while (_Msg != NULL) + { + message_status _Status = declined; + + // Always start from the first target that linked + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Target_type> * _PTarget = *_Iter; + _Status = _PTarget->propagate(_Msg, this); + + // Ownership of message changed. Do not propagate this + // message to any other target. + if (_Status == accepted) + { + break; + } + + // If the target just propagated to reserved this message, stop + // propagating it to others + if (_M_pReservedFor != NULL) + { + break; + } + } + + // If status is anything other than accepted, then the head message + // was not propagated out. Thus, nothing after it in the queue can + // be propagated out. Cease propagation. + if (_Status != accepted) + { + break; + } + + // Get the next message + _Msg = _MessageBuffer._Peek(); + } + } + + /// <summary> + /// Constructs a new message from the data output. + /// </summary> + /// <returns> + /// The created message (NULL if creation failed) + /// </returns> + /**/ + message<std::vector<_Type>> * __cdecl _Create_new_message() + { + bool fIsNonGreedy = (_Jtype == non_greedy); + + // If this is a non-greedy join, check each source and try to consume their message + if (fIsNonGreedy) + { + + // The iterator _Iter below will ensure that it is safe to touch + // non-NULL source pointers. Take a snapshot. + std::vector<ISource<_Type> *> _Sources; + source_iterator _Iter = _M_connectedSources.begin(); + + while (*_Iter != NULL) + { + ISource<_Type> * _PSource = *_Iter; + + if (_PSource == NULL) + { + break; + } + + _Sources.push_back(_PSource); + ++_Iter; + } + + if (_Sources.size() != _M_messageArray._M_count) + { + // Some of the sources were unlinked. The join is broken + return NULL; + } + + // First, try and reserve all the messages. If a reservation fails, + // then release any reservations that had been made. + for (size_t i = 0; i < _M_savedMessageIdArray._M_count; i++) + { + // Snap the current saved ID into a buffer. This value can be changing behind the scenes from + // other source->propagate(msg, this) calls, but if so, that just means the reserve below will + // fail. + _InterlockedIncrementSizeT(&_M_messagesRemaining); + _M_savedIdBuffer[i] = _InterlockedExchange((volatile long *) &_M_savedMessageIdArray._M_savedIds[i], -1); + + _CONCRT_ASSERT(_M_savedIdBuffer[i] != -1); + + if (!_Sources[i]->reserve(_M_savedIdBuffer[i], this)) + { + // A reservation failed, release all reservations made up until + // this block, and wait for another message to arrive on this link + for (size_t j = 0; j < i; j++) + { + _Sources[j]->release(_M_savedIdBuffer[j], this); + if (_InterlockedCompareExchange((volatile long *) &_M_savedMessageIdArray._M_savedIds[j], _M_savedIdBuffer[j], -1) == -1) + { + if (_InterlockedDecrementSizeT(&_M_messagesRemaining) == 0) + { + async_send(NULL); + } + } + } + + // Return NULL to indicate that the create failed + return NULL; + } + } + + // Because everything has been reserved, consume all the messages. + // This is guaranteed to return true. + for (size_t i = 0; i < _M_messageArray._M_count; i++) + { + _M_messageArray._M_messages[i] = _Sources[i]->consume(_M_savedIdBuffer[i], this); + _M_savedIdBuffer[i] = -1; + } + } + + if (!fIsNonGreedy) + { + // Reinitialize how many messages are being waited for. + // This is safe because all messages have been received, thus no new async_sends for + // greedy joins can be called. + _M_messagesRemaining = _M_messageArray._M_count; + } + + std::vector<_Type> _OutputVector; + for (size_t i = 0; i < _M_messageArray._M_count; i++) + { + _CONCRT_ASSERT(_M_messageArray._M_messages[i] != NULL); + _OutputVector.push_back(_M_messageArray._M_messages[i]->payload); + + delete _M_messageArray._M_messages[i]; + if (fIsNonGreedy) + { + _M_messageArray._M_messages[i] = NULL; + } + } + return (new message<std::vector<_Type>>(_OutputVector)); + } + + /// <summary> + /// Initializes the <c>join</c> messaging block. + /// </summary> + /// <param name="_NumInputs"> + /// The number of inputs. + /// </param> + /// <param name="_PScheduler"> + /// The scheduler onto which the task to propagate the <c>join</c> block's message will be scheduled. + /// If unspecified, the <c>join</c> messaging block uses the default scheduler. + /// </param> + /// <param name="_PScheduleGroup"> + /// The schedule group into which the task to propagate the <c>join</c> block's message will be scheduled. + /// The scheduler used is implied by the schedule group. If unspecified, the <c>join</c> uses a schedule + /// group of the scheduler's choosing. + /// </param> + /**/ + void _Initialize(size_t _NumInputs, Scheduler * _PScheduler = NULL, ScheduleGroup * _PScheduleGroup = NULL) + { + initialize_source_and_target(_PScheduler, _PScheduleGroup); + + _M_connectedSources.set_bound(_NumInputs); + _M_messagesRemaining = _NumInputs; + + bool fIsNonGreedy = (_Jtype == non_greedy); + + if (fIsNonGreedy) + { + // Non greedy joins need a buffer to snap off saved message IDs to. + _M_savedIdBuffer = new runtime_object_identity[_NumInputs]; + memset(_M_savedIdBuffer, -1, sizeof(runtime_object_identity) * _NumInputs); + } + else + { + _M_savedIdBuffer = NULL; + } + } + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Input messages for this message block are in the base-class input buffer + // All messages in that buffer are guaranteed to have moved to the output + // buffer because the destructor first waits for all async sends to finish + // before reaching this point + + // Delete any messages remaining in the output queue + for (;;) + { + message<std::vector<_Type>> * _Msg = _M_messageBuffer._Dequeue(); + if (_Msg == NULL) + { + break; + } + delete _Msg; + } + } + + // The current number of messages remaining + volatile size_t _M_messagesRemaining; + + // An array containing the accepted messages of this join. + // Wrapped in a struct to enable debugger visualization. + struct _MessageArray + { + size_t _M_count; + message<_Type>** _M_messages; + + _MessageArray(size_t _NumInputs) + : _M_count(_NumInputs), + _M_messages(new message<_Type>*[_NumInputs]) + { + memset(_M_messages, 0, sizeof(message<_Type> *) * _NumInputs); + } + + ~_MessageArray() + { + for (size_t i = 0; i < _M_count; i++) + delete _M_messages[i]; + delete [] _M_messages; + } + }; + _MessageArray _M_messageArray; + + // An array containing the msg IDs of messages propagated to the array + // For greedy joins, this contains a log of other messages passed to this + // join after the first has been accepted + // For non-greedy joins, this contains the message ID of any message + // passed to it. + // Wrapped in a struct to enable debugger visualization. + struct _SavedMessageIdArray + { + size_t _M_count; + runtime_object_identity * _M_savedIds; + + _SavedMessageIdArray(size_t _NumInputs) + : _M_count(_NumInputs), + _M_savedIds(new runtime_object_identity[_NumInputs]) + { + memset(_M_savedIds, -1, sizeof(runtime_object_identity) * _NumInputs); + } + + ~_SavedMessageIdArray() + { + delete [] _M_savedIds; + } + }; + _SavedMessageIdArray _M_savedMessageIdArray; + + // Buffer for snapping saved IDs in non-greedy joins + runtime_object_identity * _M_savedIdBuffer; + + // A lock for modifying the buffer or the connected blocks + ::Concurrency::details::_NonReentrantPPLLock _M_propagationLock; + + // Queue to hold output messages + ::Concurrency::details::_Queue<message<std::vector<_Type>>> _M_messageBuffer; +}; + + +//************************************************************************** +// Multi-Type Choice and Join helper node: +//************************************************************************** + +/// <summary> +/// Base class for Helper node used in multi-type join and choice blocks +/// Order node is a single-target, single-source ordered propagator block +/// The main property of an order node is that it accepts a message of _Type +/// and outputs a message of int, with some unique assigned index number. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/**/ +template<class _Type> +class _Order_node_base: public propagator_block<single_link_registry<ITarget<size_t>>, multi_link_registry<ISource<_Type>>> +{ +public: + + /// <summary> + /// Constructs a _Order_node_base within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /**/ + _Order_node_base() : + _M_index(0), + _M_pReceiveMessage(NULL), + _M_pSendMessage(NULL) + { + } + + /// <summary> + /// Cleans up any resources that may have been created by the _Order_node. + /// </summary> + /**/ + ~_Order_node_base() + { + // The messages for an _Order_node_base are deleted at the end when + // _Order_node_base is deleted. + delete _M_pReceiveMessage; + delete _M_pSendMessage; + } + + /// <summary> + /// Checks whether this block has been initialized yet. + /// </summary> + /// <returns> + /// true, if the block has received a value, false otherwise. + /// </returns> + /**/ + bool has_value() const + { + return (_M_pReceiveMessage != NULL); + } + + /// <summary> + /// Gets a reference to the current payload of the message being stored. + /// </summary> + /// <returns> + /// The incoming payload. + /// </returns> + /**/ + _Type const & value() + { + _CONCRT_ASSERT(_M_pReceiveMessage != NULL); + + return _M_pReceiveMessage->payload; + } + + /// <summary> + /// Resets the _Order_node_base and prepares it for the next propagation + /// </summary> + /// <remarks> + /// _Reset is called from Populate_destination_tuple through propagate_to_any_targets() + /// thus, it always has the internal lock held. This is only used for _Greedy_node and + /// _Non_greedy_node. + /// </remarks> + /**/ + virtual void _Reset() = 0; + + /// <summary> + /// Reserves a message previously offered by the source. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A bool indicating whether the reservation worked or not + /// </returns> + /// <remarks> + /// After 'reserve' is called, either 'consume' or 'release' must be called. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity) + { + // reserve should never be called for this block. + _CONCRT_ASSERT(false); + + return false; + } + + /// <summary> + /// Consumes a message previously offered by the source and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /// <remarks> + /// Similar to 'accept', but is always preceded by a call to 'reserve' + /// </remarks> + /**/ + virtual message<size_t> * consume_message(runtime_object_identity) + { + // consume should never be called for this block. + _CONCRT_ASSERT(false); + + return NULL; + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /**/ + virtual void release_message(runtime_object_identity) + { + // release should never be called for this block. + _CONCRT_ASSERT(false); + } + +protected: + + + /// <summary> + /// Resumes propagation after a reservation has been released + /// </summary> + /**/ + virtual void resume_propagation() + { + // Because there is only a single target, nothing needs + // to be done on resume + } + + /// <summary> + /// Notification that a target was linked to this source. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<size_t> *) + { + if (_M_pSendMessage != NULL) + { + propagate_to_any_targets(NULL); + } + } + + /// <summary> + /// Create a message that contains an index used to determine the source message + /// </summary> + /**/ + void _Create_send_message() + { + _M_pSendMessage = new message<size_t>(_M_index); + } + + /// <summary> + /// Validate constructor arguments and fully connect this _Order_node_base. + /// </summary> + /**/ + void _Initialize_order_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, Scheduler * _PScheduler = NULL, ScheduleGroup * _PScheduleGroup = NULL) + { + if (_Index < 0) + { + throw std::invalid_argument("_Index"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + _M_index = _Index; + + initialize_source_and_target(_PScheduler, _PScheduleGroup); + + // Allow only a single source and ensure that they + // cannot be unlinked and relinked. + _M_connectedSources.set_bound(1); + + if (_PTarget != NULL) + { + link_target(_PTarget); + } + + _PSource->link_target(this); + } + + // + // Private Data Members + // + + // The message to be received from the source + message<_Type> * _M_pReceiveMessage; + + // The message to be sent to all targets + message<size_t> * _M_pSendMessage; + + // The index of the _Order_node_base in the user's construct + size_t _M_index; + +private: + // + // Hide assignment operator and copy constructor + // + _Order_node_base const & operator=(_Order_node_base const &); // no assignment operator + _Order_node_base(_Order_node_base const &); // no copy constructor +}; + + +/// <summary> +/// Helper class used in multi-type choice blocks +/// Ordered node is a single-target, single-source ordered propagator block +/// </summary> +/// +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/**/ +template<class _Type> +class _Reserving_node: public _Order_node_base<_Type> +{ +public: + /// <summary> + /// Constructs a _Reserving_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Reserving_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Reserving_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Reserving_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Reserving_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Reserving_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Reserving_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Reserving_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Order_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Reserving_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs a _Order_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Reserving_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_fIsInitialized(false), + _M_savedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Cleans up any resources that may have been created by the _Reserving_node. + /// </summary> + /**/ + ~_Reserving_node() + { + if (_M_pReservedSource != NULL) + { + _M_pReservedSource = NULL; + _M_connectedSources.release(); + } + + // Remove all links + remove_network_links(); + } + + + /// <summary> + /// Resets the _Reserving_node and prepares it for the next propagation + /// </summary> + /// <remarks> + /// This function is not used in a _Reserving_node, which is only used for choice blocks + /// </remarks> + /**/ + virtual void _Reset() + { + } + +protected: + + // + // propagator_block protected function implementation + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>ITarget</c> block. It is invoked + /// by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// It is important that calls to propagate do *not* take the same lock on the + /// internal structure that is used by Consume and the light-weight task. Doing so could + /// result in a deadlock with the Consume call. + /// </remarks> + /**/ + virtual message_status propagate_message(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + message_status _Result = postponed; + + // _Order_node messaging block can be initialized only once, just like single_assignment. + if (_M_fIsInitialized) + { + return declined; + } + + // Reserve a message on the source until this _Order_node gets the feedback from + // the single_assignment on whether it has been selected. + _M_fIsInitialized = _PSource->reserve(_PMessage->msg_id(), this); + + // + // If message was successfully reserved, set the member variables for + // this messaging block and start the asynchronous propagation task. + // + if (_M_fIsInitialized) + { + _M_savedId = _PMessage->msg_id(); + async_send(NULL); + } + else + { + _Result = missed; + } + + return _Result; + } + + /// <summary> + /// Accept the message by making a copy of the payload. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<size_t> * accept_message(runtime_object_identity _MsgId) + { + // This check is to prevent spoofing and verify that the propagated message is + // the one that is accepted at the end. + if (_M_pSendMessage == NULL || _MsgId != _M_pSendMessage->msg_id()) + { + return NULL; + } + + // If the source has disconnected then we can't allow for accept to succeed. + source_iterator _Iter = _M_connectedSources.begin(); + ISource<_Type>* _PSource = *_Iter; + + if (_PSource == NULL) + { + // source was disconnected. Fail accept. + return NULL; + } + + _M_pReceiveMessage = _PSource->consume(_M_savedId, this); + + _CONCRT_ASSERT(_M_pReceiveMessage != NULL); + + // + // Instead of returning the internal message, we return a copy of the + // message passed in. + // + // Because we are returning a copy, the accept routine for a _Order_node + // does not need to grab the internal lock. + // + return (new message<size_t>(_M_pSendMessage->payload)); + } + + /// <summary> + /// Takes the message and propagates it to all the targets of this _Order_node + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a new message. + /// </param> + /// <remarks> + /// This function packages its _M_index into a message and immediately sends it to the targets. + /// </remarks> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<size_t> *) + { + if (_M_pSendMessage == NULL) + { + _Create_send_message(); + } + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<size_t> * _PTarget = *_Iter; + _Propagate_to_target(_PTarget); + } + } + +private: + + /// <summary> + /// Propagate messages to the given target + /// </summary> + /**/ + message_status _Propagate_to_target(ITarget<size_t> * _PTarget) + { + message_status _Status = _PTarget->propagate(_M_pSendMessage, this); + + // If the message got rejected we have to release the hold on the source message. + if (_Status != accepted) + { + if (_M_savedId != -1) + { + // Release the reservation + source_iterator _Iter = _M_connectedSources.begin(); + ISource<_Type> * _PSource = *_Iter; + + if (_PSource != NULL) + { + _PSource->release(_M_savedId, this); + } + + // If the source was disconnected, then it would + // automatically release any reservation. So we + // should reset our savedId regardless. + _M_savedId = -1; + } + + } + + return _Status; + } + + // + // Private Data Members + // + + // The source where we have reserved a message + ISource<_Type> * _M_pReservedSource; + + // For greedy order-nodes, the message ID of subsequent messages sent to this node + // For non-greedy order nodes, the message ID of the message to reserve/consume + runtime_object_identity _M_savedId; + + // The marker that indicates that _Reserving_node has reserved a message + volatile bool _M_fIsInitialized; + +private: + // + // Hide assignment operator and copy constructor + // + _Reserving_node const & operator=(_Reserving_node const &); // no assignment operator + _Reserving_node(_Reserving_node const &); // no copy constructor +}; + + +/// <summary> +/// Helper class used in multi-type greedy join blocks +/// Ordered node is a single-target, single-source ordered propagator block +/// </summary> +/// +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/**/ +template<class _Type> +class _Greedy_node: public _Order_node_base<_Type> +{ +public: + /// <summary> + /// Constructs a _Greedy_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Greedy_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Greedy_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Greedy_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Greedy_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Greedy_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Greedy_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Greedy_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Greedy_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Greedy_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs a _Greedy_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Greedy_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_pGreedyMessage(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Cleans up any resources that may have been created by the _Greedy_node. + /// </summary> + /**/ + ~_Greedy_node() + { + // Remove all links + remove_network_links(); + + if (_M_pGreedyMessage != _M_pReceiveMessage) + { + delete _M_pGreedyMessage; + } + } + + /// <summary> + /// Resets the _Greedy_node and prepares it for the next propagation + /// </summary> + /// <remarks> + /// _Reset is called from Populate_destination_tuple through propagate_to_any_targets() + /// thus, it always has the internal lock held. + /// </remarks> + /**/ + void _Reset() + { + _R_lock _Lock(_M_resetLock); + + delete _M_pReceiveMessage; + _M_pReceiveMessage = NULL; + + delete _M_pSendMessage; + _M_pSendMessage = NULL; + + // + // For greedy type joins, look to see if any other messages have been + // passed to this _Greedy_node while the join was waiting for other + // messages to arrive. This function is already called with _M_resetLock + // held through propagate_to_any_targets(). + // + for(;;) + { + // Set the current saved ID as -1. Check to see if something was ready for consumption + // (if _Saved_id != -1) and consume it if possible. + runtime_object_identity _Saved_id; + + { + _NR_lock lockHolder(_M_propagationLock); + + _Saved_id = _M_savedId; + + if (_Saved_id == -1) + { + _M_pGreedyMessage = NULL; + break; + } + else + { + _M_savedId = -1; + } + } + + if (_Saved_id != -1) + { + source_iterator _Iter = _M_connectedSources.begin(); + + ISource<_Type> * _PSource = *_Iter; + if ((_PSource != NULL) && _PSource->reserve(_Saved_id, this)) + { + _M_pGreedyMessage = _PSource->consume(_Saved_id, this); + async_send(NULL); + break; + } + } + } + } + +protected: + + // + // propagator_block protected function implementation + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>ITarget</c> block. It is invoked + /// by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// It is important that calls to propagate do *not* take the same lock on the + /// internal structure that is used by Consume and the light-weight task. Doing so could + /// result in a deadlock with the Consume call. + /// </remarks> + /**/ + virtual message_status propagate_message(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + message_status _Result = postponed; + + bool _FDone = false; + + { + _NR_lock lockHolder(_M_propagationLock); + if (_M_pGreedyMessage != NULL) + { + _M_savedId = _PMessage->msg_id(); + _Result = postponed; + _FDone = true; + } + } + + if (!_FDone) + { + _M_pGreedyMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_M_pGreedyMessage != NULL) + { + _Result = accepted; + async_send(NULL); + } + else + { + _Result = missed; + } + } + + return _Result; + } + + /// <summary> + /// Accept the message by making a copy of the payload. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<size_t> * accept_message(runtime_object_identity _MsgId) + { + // This check is to prevent spoofing and verify that the propagated message is + // the one that is accepted at the end. + if (_M_pSendMessage == NULL || _MsgId != _M_pSendMessage->msg_id()) + { + return NULL; + } + + // + // Instead of returning the internal message, we return a copy of the + // message passed in. + // + // Because we are returning a copy, the accept routine for a _Greedy_node + // does not need to grab the internal lock. + // + return (new message<size_t>(_M_pSendMessage->payload)); + } + + + /// <summary> + /// Takes the message and propagates it to all the targets of this _Greedy_node + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a new message. + /// </param> + /// <remarks> + /// This function packages its _M_index into a message and immediately sends it to the targets. + /// </remarks> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<size_t> *) + { + _R_lock _Lock(_M_resetLock); + + if (_M_pSendMessage == NULL) + { + // Save the incoming message so that it can be consumed in the accept function + _M_pReceiveMessage = _M_pGreedyMessage; + _Create_send_message(); + } + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<size_t> * _PTarget = *_Iter; + _PTarget->propagate(_M_pSendMessage, this); + } + } + +private: + + // + // Private Data Members + // + + // The message to be saved by a greedy order node + message<_Type> * _M_pGreedyMessage; + + // The lock used to protect propagation + ::Concurrency::details::_NonReentrantPPLLock _M_propagationLock; + + // The lock used to protect modification during a reset + ::Concurrency::details::_ReentrantPPLLock _M_resetLock; + + // For greedy order-nodes, the message ID of subsequent messages sent to this node + // For non-greedy order nodes, the message ID of the message to reserve/consume + runtime_object_identity _M_savedId; + +private: + // + // Hide assignment operator and copy constructor + // + _Greedy_node const & operator=(_Greedy_node const &); // no assignment operator + _Greedy_node(_Greedy_node const &); // no copy constructor +}; + + +/// <summary> +/// Helper class used in multi-type non-greedy join blocks +/// Ordered node is a single-target, single-source ordered propagator block +/// </summary> +/// +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/**/ +template<class _Type> +class _Non_greedy_node: public _Order_node_base<_Type> +{ +public: + /// <summary> + /// Constructs a _Non_greedy_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Non_greedy_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Non_greedy_node within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Non_greedy_node(ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget); + } + + /// <summary> + /// Constructs a _Non_greedy_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Non_greedy_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Non_greedy_node within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Non_greedy_node(Scheduler& _PScheduler, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, &_PScheduler); + } + + /// <summary> + /// Constructs a _Non_greedy_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /**/ + _Non_greedy_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget = NULL) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Constructs a _Non_greedy_node within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /// <param name="_PSource"> + /// The source of data passed into the node + /// </param> + /// <param name="_Index"> + /// The node's index, assigned from the outside. + /// </param> + /// <param name="_PTarget"> + /// The target to which the node will signal about having received its input data + /// </param> + /// <param name="_Filter"> + /// A reference to a filter function. + /// </param> + /**/ + _Non_greedy_node(ScheduleGroup& _PScheduleGroup, ISource<_Type> * _PSource, size_t _Index, ITarget<size_t> * _PTarget, filter_method const& _Filter) : + _M_savedId(-1), + _M_reservedId(-1), + _M_pReservedSource(NULL) + { + register_filter(_Filter); + _Initialize_order_node(_PSource, _Index, _PTarget, NULL, &_PScheduleGroup); + } + + /// <summary> + /// Cleans up any resources that may have been created by the _Order_node. + /// </summary> + /**/ + ~_Non_greedy_node() + { + if (_M_pReservedSource != NULL) + { + _M_pReservedSource = NULL; + _M_connectedSources.release(); + } + + // Remove all links + remove_network_links(); + } + + /// <summary> + /// Resets the _Order_node and prepares it for the next propagation + /// </summary> + /// <remarks> + /// _Reset is called from Populate_destination_tuple through propagate_to_any_targets() + /// thus, it always has the internal lock held. + /// </remarks> + /**/ + void _Reset() + { + _R_lock _Lock(_M_resetLock); + + delete _M_pReceiveMessage; + _M_pReceiveMessage = NULL; + + delete _M_pSendMessage; + _M_pSendMessage = NULL; + } + + /// <summary> + /// Called for a non_greedy type join block in order to reserve the message + /// in this join block + /// </summary> + /// <returns> + /// A bool indicating whether the reservation worked + /// </returns> + /**/ + bool _Reserve_received_message() + { + bool _Ret_val = false; + + // Order node has only a single source. + // Obtain an iterator to the first source. It will guarantee that the reference + // count on the source is maintained + source_iterator _Iter = _M_connectedSources.begin(); + ISource<_Type> * _PSource = *_Iter; + + if (_PSource != NULL) + { + // CAS out the current saved ID, in order to try and reserve it + runtime_object_identity _SavedId = _InterlockedExchange((volatile long *) &_M_savedId, -1); + + _Ret_val = _PSource->reserve(_SavedId, this); + // + // If this reserved failed, that means we need to wait for another message + // to come in on this link. _M_savedID was set to -1 to indicate to the _Order_node + // that it needs to async_send when that next message comes through + // + // If the reserve succeeds, save away the reserved ID. This will be use later in + // consume + // + if (_Ret_val) + { + _M_reservedId = _SavedId; + + // Acquire a reference on the source + _M_connectedSources.reference(); + _M_pReservedSource = _PSource; + } + } + + return _Ret_val; + } + + /// <summary> + /// Called for a non_greedy type join block in order to consume the message + /// in this join block that has been reserved + /// </summary> + /**/ + void _Consume_received_message() + { + if (_M_pReservedSource != NULL) + { + runtime_object_identity _SavedId = _M_reservedId; + _M_pReceiveMessage = _M_pReservedSource->consume(_SavedId, this); + + runtime_object_identity _OldId = NULL; + _OldId = _InterlockedExchange((volatile long *) &_M_reservedId, -1); + + _CONCRT_ASSERT(_OldId == _SavedId); + + // Release the reference on the source + _M_pReservedSource = NULL; + _M_connectedSources.release(); + } + } + + /// <summary> + /// Called for a non_greedy type join block release a reservation on this block + /// </summary> + /**/ + bool _Release_received_message() + { + bool retVal = false; + + if (_M_pReservedSource != NULL) + { + runtime_object_identity _SavedId = _M_reservedId; + // If the _M_savedId is still -1, then swap the succeeded one back + _M_pReservedSource->release(_SavedId, this); + + if (_InterlockedCompareExchange((volatile long *) &_M_savedId, _SavedId, -1) == -1) + { + retVal = true; + } + + // Release the reference on the source + _M_pReservedSource = NULL; + _M_connectedSources.release(); + } + + return retVal; + } + +protected: + + // + // propagator_block protected function implementation + // + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>ITarget</c> block. It is invoked + /// by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /// <remarks> + /// It is important that calls to propagate do *not* take the same lock on the + /// internal structure that is used by Consume and the light-weight task. Doing so could + /// result in a deadlock with the Consume call. + /// </remarks> + /**/ + virtual message_status propagate_message(message<_Type> * _PMessage, ISource<_Type> *) + { + // Change the message ID. If it was -1, that means an async-send needs to occur + if (_InterlockedExchange((volatile long *) &_M_savedId, _PMessage->msg_id()) == -1) + { + async_send(NULL); + } + + // Always return postponed. This message will be consumed + // in the LWT + + return postponed; + } + + /// <summary> + /// Accept the message by making a copy of the payload. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<size_t> * accept_message(runtime_object_identity _MsgId) + { + // This check is to prevent spoofing and verify that the propagated message is + // the one that is accepted at the end. + if (_M_pSendMessage == NULL || _MsgId != _M_pSendMessage->msg_id()) + { + return NULL; + } + + // + // Instead of returning the internal message, we return a copy of the + // message passed in. + // + // Because we are returning a copy, the accept routine for a _Non_greedy_node + // does not need to grab the internal lock. + // + return (new message<size_t>(_M_pSendMessage->payload)); + } + + /// <summary> + /// Takes the message and propagates it to all the targets of this _Order_node + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a new message. + /// </param> + /// <remarks> + /// This function packages its _M_index into a message and immediately sends it to the targets. + /// </remarks> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<size_t> *) + { + _R_lock _Lock(_M_resetLock); + + if (_M_pSendMessage == NULL) + { + _Create_send_message(); + } + + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<size_t> * _PTarget = *_Iter; + _PTarget->propagate(_M_pSendMessage, this); + } + } + +private: + + // + // Private Data Members + // + + // The source where we have reserved a message + ISource<_Type> * _M_pReservedSource; + + // The lock used to protect modification during a reset + ::Concurrency::details::_ReentrantPPLLock _M_resetLock; + + // For non-greedy order nodes, the message ID of the message to reserve/consume + runtime_object_identity _M_savedId; + + // For non-greedy order nodes, the reserved ID of the message that was reserved + runtime_object_identity _M_reservedId; + + // The marker that indicates that _Non_greedy_node has reserved a message + volatile bool _M_fIsInitialized; + +private: + // + // Hide assignment operator and copy constructor + // + _Non_greedy_node const & operator=(_Non_greedy_node const &); // no assignment operator + _Non_greedy_node(_Non_greedy_node const &); // no copy constructor +}; + +//************************************************************************** +// Choice: +//************************************************************************** + +/// <summary> +/// A <c>choice</c> messaging block is a multi-source, single-target block that represents a control-flow +/// interaction with a set of sources. The choice block will wait for any one of multiple sources to +/// produce a message and will propagate the index of the source that produced the message. +/// </summary> +/// <typeparam name="_Type"> +/// A <c>tuple</c>-based type representing the payloads of the input sources. +/// </typeparam> +/// <remarks> +/// The choice block ensures that only one of the incoming messages is consumed. +/// <para>For more information, see <see cref="Asynchronous Message Blocks"/>.</para> +/// </remarks> +/// <seealso cref="join Class"/> +/// <seealso cref="single_assignment Class"/> +/// <seealso cref="make_choice Function"/> +/// <seealso cref="tuple Class"/> +/**/ +template<class _Type> +class choice: public ISource<size_t> +{ +public: + + /// <summary> + /// Constructs a <c>choice</c> messaging block. + /// </summary> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for the choice. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + explicit choice(_Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(NULL), _M_pScheduleGroup(NULL) + { + _M_pSingleAssignment = new single_assignment<size_t>(); + _Initialize_choices<0>(); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>choice</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>choice</c> messaging block is scheduled. + /// </param> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for the choice. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + choice(Scheduler& _PScheduler, _Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(&_PScheduler), _M_pScheduleGroup(NULL) + { + _M_pSingleAssignment = new single_assignment<size_t>(_PScheduler); + _Initialize_choices<0>(); + } + + /// <summary> + /// Constructs a <c>choice</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>choice</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for the choice. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + choice(ScheduleGroup& _PScheduleGroup, _Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(NULL), _M_pScheduleGroup(&_PScheduleGroup) + { + _M_pSingleAssignment = new single_assignment<size_t>(_PScheduleGroup); + _Initialize_choices<0>(); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Constructs a <c>choice</c> messaging block. + /// </summary> + /// <param name="_Choice"> + /// A <c>choice</c> messaging block to copy from. + /// Note that the original object is orphaned, making this a move constructor. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + choice(choice && _Choice) + { + // Copy scheduler group or scheduler to the new object. + _M_pScheduleGroup = _Choice._M_pScheduleGroup; + _M_pScheduler = _Choice._M_pScheduler; + + // Single assignment is heap allocated, so simply copy the pointer. If it already has + // a value, it will be preserved. + _M_pSingleAssignment = _Choice._M_pSingleAssignment; + _Choice._M_pSingleAssignment = NULL; + + // Invoke copy assignment for tuple to copy pointers to message blocks. + _M_sourceTuple = _Choice._M_sourceTuple; + + // Copy the pointers to order nodes to a new object and zero out in the old object. + memcpy(_M_pSourceChoices, _Choice._M_pSourceChoices, sizeof(_M_pSourceChoices)); + memset(_Choice._M_pSourceChoices, 0, sizeof(_M_pSourceChoices)); + } + + /// <summary> + /// Destroys the <c>choice</c> messaging block. + /// </summary> + /**/ + ~choice() + { + delete _M_pSingleAssignment; + _Delete_choices<0>(); + } + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type type; + + /// <summary> + /// Checks whether this <c>choice</c> messaging block has been initialized with a value yet. + /// </summary> + /// <returns> + /// <c>true</c> if the block has received a value, <c>false</c> otherwise. + /// </returns> + /**/ + bool has_value() const + { + return _M_pSingleAssignment->has_value(); + } + + /// <summary> + /// Returns an index into the <c>tuple</c> representing the element selected by the + /// <c>choice</c> messaging block. + /// </summary> + /// <returns> + /// The message index. + /// </returns> + /// <remarks> + /// The message payload can be extracted using the <c>get</c> method. + /// </remarks> + /**/ + size_t index() + { + return _M_pSingleAssignment->value(); + } + + /// <summary> + /// Gets the message whose index was selected by the <c>choice</c> messaging block. + /// </summary> + /// <typeparam name="_Payload_type"> + /// The type of the message payload. + /// </typeparam> + /// <returns> + /// The payload of the message. + /// </returns> + /// <remarks> + /// Because a <c>choice</c> messaging block can take inputs with different payload types, you must specify + /// the type of the payload at the point of retrieval. You can determine the type based on the result of + /// the <c>index</c> method. + /// </remarks> + /**/ + template <typename _Payload_type> + _Payload_type const & value() + { + return reinterpret_cast<_Reserving_node<_Payload_type> *>(_M_pSourceChoices[_M_pSingleAssignment->value()])->value(); + } + + // + // ISource public function implementations + // + + /// <summary> + /// Links a target block to this <c>choice</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to link to this <c>choice</c> messaging block. + /// </param> + /**/ + virtual void link_target(_Inout_ ITarget<size_t> * _PTarget) + { + _M_pSingleAssignment->link_target(_PTarget); + } + + /// <summary> + /// Unlinks a target block from this <c>choice</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to unlink from this <c>choice</c> messaging block. + /// </param> + /**/ + virtual void unlink_target(_Inout_ ITarget<size_t> * _PTarget) + { + _M_pSingleAssignment->unlink_target(_PTarget); + } + + /// <summary> + /// Unlinks all targets from this <c>choice</c> messaging block. + /// </summary> + /// <remarks> + /// This method does not need to be called from the destructor because destructor for the internal + /// <c>single_assignment</c> block will unlink properly. + /// </remarks> + /**/ + virtual void unlink_targets() + { + _M_pSingleAssignment->unlink_targets(); + } + + /// <summary> + /// Accepts a message that was offered by this <c>choice</c> block, transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>accept</c> method. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<size_t> * accept(runtime_object_identity _MsgId, _Inout_ ITarget<size_t> * _PTarget) + { + return _M_pSingleAssignment->accept(_MsgId, _PTarget); + } + + /// <summary> + /// Reserves a message previously offered by this <c>choice</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>reserve</c> method. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. Reservations can fail + /// for many reasons, including: the message was already reserved or accepted by another target, the source could + /// deny reservations, and so forth. + /// </returns> + /// <remarks> + /// After you call <c>reserve</c>, if it succeeds, you must call either <c>consume</c> or <c>release</c> + /// in order to take or give up possession of the message, respectively. + /// </remarks> + /**/ + virtual bool reserve(runtime_object_identity _MsgId, _Inout_ ITarget<size_t> * _PTarget) + { + return _M_pSingleAssignment->reserve(_MsgId, _PTarget); + } + + /// <summary> + /// Consumes a message previously offered by this <c>choice</c> messaging block and successfully reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>consume</c> method. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>consume</c> method is similar to <c>accept</c>, but must always be preceded by a call to <c>reserve</c> that + /// returned <c>true</c>. + /// </remarks> + /**/ + virtual message<size_t> * consume(runtime_object_identity _MsgId, _Inout_ ITarget<size_t> * _PTarget) + { + return _M_pSingleAssignment->consume(_MsgId, _PTarget); + } + + /// <summary> + /// Releases a previous successful message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>release</c> method. + /// </param> + /**/ + virtual void release(runtime_object_identity _MsgId, _Inout_ ITarget<size_t> * _PTarget) + { + _M_pSingleAssignment->release(_MsgId, _PTarget); + } + + /// <summary> + /// Acquires a reference count on this <c>choice</c> messaging block, to prevent deletion. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being linked to this source + /// during the <c>link_target</c> method. + /// </remarks> + /**/ + virtual void acquire_ref(_Inout_ ITarget<size_t> * _PTarget) + { + _M_pSingleAssignment->acquire_ref(_PTarget); + } + + /// <summary> + /// Releases a reference count on this <c>choice</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being unlinked from this source. + /// The source block is allowed to release any resources reserved for the target block. + /// </remarks> + /**/ + virtual void release_ref(_Inout_ ITarget<size_t> * _PTarget) + { + _M_pSingleAssignment->release_ref(_PTarget); + } + +private: + + /// <summary> + /// Constructs and initializes a _Reserving_node for each tuple messaging block passed in. + /// </summary> + /// <typeparam>The highest-number index of the choice's sources</typeparam> + /**/ + template<int _Index> + void _Initialize_choices() + { + std::tr1::tuple_element<_Index, _Type>::type _Item = std::tr1::get<_Index>(_M_sourceTuple); + _Reserving_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> * _Order_node_element = NULL; + + if (_M_pScheduleGroup != NULL) + { + _Order_node_element = new _Reserving_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduleGroup, _Item, _Index); + } + else if (_M_pScheduler != NULL) + { + _Order_node_element = new _Reserving_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduler, _Item, _Index); + } + else + { + _Order_node_element = new _Reserving_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (_Item, _Index); + } + + _M_pSourceChoices[_Index] = _Order_node_element; + _Order_node_element->link_target(_M_pSingleAssignment); + _Initialize_choices<_Index + 1>(); + } + + /// <summary> + /// Provides a sentinel template specialization for _Initialize_choices recursive + /// template expansion. + /// </summary> + /**/ + template<> void _Initialize_choices<std::tr1::tuple_size<_Type>::value>() + { + } + + /// <summary> + /// Deletes all _Reserving_node elements that were created in _Initialize_choices. + /// </summary> + /// <typeparam>The highest-number index of the choice's sources</typeparam> + /**/ + template<int _Index> + void _Delete_choices() + { + delete reinterpret_cast<_Reserving_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> *>(_M_pSourceChoices[_Index]); + _M_pSourceChoices[_Index] = NULL; + _Delete_choices<_Index + 1>(); + } + + /// <summary> + /// Provides a sentinel template specialization for _Delete_choices recursive + /// template expansion. + /// </summary> + /**/ + template<> void _Delete_choices<std::tr1::tuple_size<_Type>::value>() + { + } + + // Array of pointers to _Reserving_node elements representing each source + void * _M_pSourceChoices[std::tr1::tuple_size<_Type>::value]; + + // Single assignment which chooses between source messaging blocks + single_assignment<size_t> * _M_pSingleAssignment; + + // Tuple of messaging blocks that are sources to this choice + _Type _M_sourceTuple; + + // The scheduler to propagate messages on + Scheduler * _M_pScheduler; + + // The schedule group to propagate messages on + ScheduleGroup * _M_pScheduleGroup; + +private: + // + // Hide assignment operator + // + choice const &operator =(choice const &); // no assignment operator + choice(choice const &); // no copy constructor +}; + +// Templated factory functions that create a choice, three flavors + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +/// <summary> +/// Constructs a <c>choice</c> messaging block from an optional <c>Scheduler</c> or <c>ScheduleGroup</c> +/// and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduler"> +/// The <c>Scheduler</c> object within which the propagation task for the <c>choice</c> messaging block is scheduled. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>choice</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="choice Class"/> +/// <seealso cref="Scheduler Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +choice<std::tuple<_Type1, _Type2, _Types...>> +make_choice(Scheduler& _PScheduler, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return choice<std::tuple<_Type1, _Type2, _Types...>>(_PScheduler, std::make_tuple(_Item1, _Item2, _Items...)); +} + +/// <summary> +/// Constructs a <c>choice</c> messaging block from an optional <c>Scheduler</c> or <c>ScheduleGroup</c> +/// and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduleGroup"> +/// The <c>ScheduleGroup</c> object within which the propagation task for the <c>choice</c> messaging block is scheduled. +/// The <c>Scheduler</c> object used is implied by the schedule group. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>choice</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="choice Class"/> +/// <seealso cref="ScheduleGroup Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +choice<std::tuple<_Type1, _Type2, _Types...>> +make_choice(ScheduleGroup& _PScheduleGroup, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return choice<std::tuple<_Type1, _Type2, _Types...>>(_PScheduleGroup, std::make_tuple(_Item1, _Item2, _Items...)); +} + +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + +/// <summary> +/// Constructs a <c>choice</c> messaging block from an optional <c>Scheduler</c> or <c>ScheduleGroup</c> +/// and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>choice</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="choice Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +choice<std::tuple<_Type1, _Type2, _Types...>> +make_choice(_Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return choice<std::tuple<_Type1, _Type2, _Types...>>(std::make_tuple(_Item1, _Item2, _Items...)); +} + +//************************************************************************** +// Join: +//************************************************************************** + +// Template specialization used to unwrap the types from within a tuple. + +/**/ +template <typename _Tuple> struct _Unwrap; + +/// <summary> +/// Template specialization used to unwrap the types from within a tuple. +/// </summary> +/// <typeparam name="_Types"> +/// The types of the elements of the tuple. +/// </typeparam> +/**/ +template <typename... _Types> +struct _Unwrap<std::tuple<_Types...>> +{ + typedef std::tuple<typename std::remove_pointer<_Types>::type::source_type...> type; +}; + +/// <summary> +/// Defines a block allowing sources of distinct types to be joined. +/// Join node is a single-target, multi-source ordered propagator block +/// </summary> +/// <typeparam name="_Type"> +/// The payload tuple type +/// </typeparam> +/// <typeparam name="_Jtype"> +/// The kind of join this is, either 'greedy' or 'non-greedy' +/// </typeparam> +/**/ +template<typename _Type, typename _Destination_type, join_type _Jtype> +class _Join_node: public propagator_block<single_link_registry<ITarget<_Destination_type>>, multi_link_registry<ISource<size_t>>> +{ +public: + + /// <summary> + /// Constructs a join within the default scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /**/ + _Join_node() : _M_counter(std::tr1::tuple_size<_Destination_type>::value) + { + initialize_source_and_target(); + } + + /// <summary> + /// Constructs a join within the specified scheduler, and places it on any schedule + /// group of the scheduler's choosing. + /// </summary> + /// <param name="_PScheduler"> + /// A reference to a scheduler instance. + /// </param> + /**/ + _Join_node(Scheduler& _PScheduler) : _M_counter(std::tr1::tuple_size<_Destination_type>::value) + { + initialize_source_and_target(&_PScheduler); + } + + /// <summary> + /// Constructs a join within the specified schedule group. The scheduler is implied + /// by the schedule group. + /// </summary> + /// <param name="_PScheduleGroup"> + /// A reference to a schedule group. + /// </param> + /**/ + _Join_node(ScheduleGroup& _PScheduleGroup) : _M_counter(std::tr1::tuple_size<_Destination_type>::value) + { + initialize_source_and_target(NULL, &_PScheduleGroup); + } + + /// <summary> + /// Cleans up any resources that may have been created by the join. + /// </summary> + /**/ + ~_Join_node() + { + // Remove all links + remove_network_links(); + + // Clean up any messages left in this message block + _Delete_stored_messages(); + } + +protected: + + /// <summary> + /// Asynchronously passes a message from an <c>ISource</c> block to this <c>ITarget</c> block. It is invoked + /// by the <c>propagate</c> method, when called by a source block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to the <c>message</c> object. + /// </param> + /// <param name="_PSource"> + /// A pointer to the source block offering the message. + /// </param> + /// <returns> + /// A <see cref="message_status Enumeration">message_status</see> indication of what + /// the target decided to do with the message. + /// </returns> + /**/ + virtual message_status propagate_message(message<size_t> * _PMessage, ISource<size_t> * _PSource) + { + // This join block is connected to the _Order_node sources, which know not to send + // any more messages until join propagates them further. That is why join can + // always accept the incoming messages. + + _PMessage = _PSource->accept(_PMessage->msg_id(), this); + + // + // Source block created an int message only to notify join that the real + // payload is available. There is no need to keep this message around. + // + _CONCRT_ASSERT(_PMessage != NULL); + delete _PMessage; + + long _Ret_val = _InterlockedDecrement(&_M_counter); + + _CONCRT_ASSERT(_Ret_val >= 0); + + if (_Ret_val == 0) + { + // + // All source messages are now received so join can propagate them further + // + async_send(NULL); + } + + return accepted; + } + + /// <summary> + /// Accepts an offered message by the source, transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_Destination_type> * accept_message(runtime_object_identity _MsgId) + { + // + // Peek at the head message in the message buffer. If the IDs match + // dequeue and transfer ownership + // + message<_Destination_type> * _Msg = NULL; + + if (_M_messageBuffer._Is_head(_MsgId)) + { + _Msg = _M_messageBuffer._Dequeue(); + } + + return _Msg; + } + + /// <summary> + /// Reserves a message previously offered by the source. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A bool indicating whether the reservation worked or not. + /// </returns> + /// <remarks> + /// After <c>reserve</c> is called, if it returns <c>true</c>, either <c>consume</c> or <c>release</c> must be called + /// to either take or release ownership of the message. + /// </remarks> + /**/ + virtual bool reserve_message(runtime_object_identity _MsgId) + { + // Allow reservation if this is the head message + return _M_messageBuffer._Is_head(_MsgId); + } + + /// <summary> + /// Consumes a message previously offered by the source and reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /// <remarks> + /// <c>consume_message</c> is similar to <c>accept</c>, but is always preceded by a call to <c>reserve</c>. + /// </remarks> + /**/ + virtual message<_Destination_type> * consume_message(runtime_object_identity _MsgId) + { + // By default, accept the message + return accept_message(_MsgId); + } + + /// <summary> + /// Releases a previous message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The runtime object identity of the message. + /// </param> + /**/ + virtual void release_message(runtime_object_identity _MsgId) + { + // The head message is the one reserved. + if (!_M_messageBuffer._Is_head(_MsgId)) + { + throw message_not_found(); + } + } + + /// <summary> + /// Resumes propagation after a reservation has been released + /// </summary> + /**/ + virtual void resume_propagation() + { + // If there are any messages in the buffer, propagate them out + if (_M_messageBuffer._Count() > 0) + { + async_send(NULL); + } + } + + /// <summary> + /// Notification that a target was linked to this source. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the newly linked target. + /// </param> + /**/ + virtual void link_target_notification(_Inout_ ITarget<_Destination_type> *) + { + // There is only a single target. + _Propagate_priority_order(_M_messageBuffer); + } + + /// <summary> + /// Takes the message and propagates it to all the targets of this <c>join</c> block. + /// </summary> + /// <param name="_PMessage"> + /// A pointer to a new message. + /// </param> + /// <remarks> + /// This function packages source payloads into a tuple message and immediately sends it to the targets. + /// </remarks> + /**/ + virtual void propagate_to_any_targets(_Inout_opt_ message<_Destination_type> *) + { + message<_Destination_type> * _Msg = NULL; + + if (_M_counter == 0) + { + bool fIsNonGreedy = (_Jtype == non_greedy); + + if (fIsNonGreedy) + { + if (!_Non_greedy_acquire_messages()) + { + return; + } + } + + if (!fIsNonGreedy) + { + // Because a greedy join has captured all input, we can reset + // the counter to the total number of inputs + _InterlockedExchange(&_M_counter, std::tr1::tuple_size<_Destination_type>::value); + } + + _Msg = _Create_send_message(); + } + + if (_Msg != NULL) + { + _M_messageBuffer._Enqueue(_Msg); + + if (!_M_messageBuffer._Is_head(_Msg->msg_id())) + { + // another message is at the head of the outbound message queue and blocked + // simply return + return; + } + } + + _Propagate_priority_order(_M_messageBuffer); + } + +private: + + /// <summary> + /// Tries to reserve from all sources. If successful, it will consume all the messages + /// </summary> + /// <returns> + /// A bool indicating whether the consumption attempt worked. + /// </returns> + /// <typeparam name="_Index"> + /// The highest-number index of the join's sources + /// </typeparam> + /**/ + template<int _Index> + bool _Try_consume_source_messages(_Destination_type & _Destination_tuple, ISource<size_t> ** _Sources) + { + _Non_greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> * _Node = + static_cast<_Non_greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> *>(_Sources[_Index]); + + // Increment the counter once for each reservation + _InterlockedIncrement(&_M_counter); + + if (_Node->_Reserve_received_message()) + { + bool _Ret_val = _Try_consume_source_messages<_Index + 1>(_Destination_tuple, _Sources); + + if (_Ret_val) + { + _Node->_Consume_received_message(); + } + else + { + if (_Node->_Release_received_message()) + { + // If _Release_received_message() restored the ID, decrement the count for that + // restoration + if (_InterlockedDecrement(&_M_counter) == 0) + { + async_send(NULL); + } + } + } + + return _Ret_val; + } + + return false; + } + + /// <summary> + /// Provides a sentinel template specialization for _Try_consume_source_messages recursive + /// template expansion. + /// </summary> + /// <returns> + /// A bool indicating whether the consumption attempt worked. + /// </returns> + /**/ + template<> bool _Try_consume_source_messages<std::tr1::tuple_size<_Type>::value>(_Destination_type &, ISource<size_t> **) + { + return true; + } + + /// <summary> + /// Tries to acquire all of the messages from the _Non_greedy_nodes. Each node has already + /// indicated that it has received a message that it can try to reserve. This function + /// starts the reservation and consume process. + /// </summary> + /// <returns> + /// A bool indicating whether the reserve/consume of all messages succeeded. + /// </returns> + /**/ + bool _Non_greedy_acquire_messages() + { + _Destination_type _Destination_tuple; + + // Populate the sources buffer + ISource<size_t> * _Sources[std::tr1::tuple_size<_Type>::value]; + size_t _Index = 0; + + // Get an iterator which will keep a reference on the connected sources + source_iterator _Iter = _M_connectedSources.begin(); + + while (*_Iter != NULL) + { + ISource<size_t> * _PSource = *_Iter; + + if (_PSource == NULL) + { + // One of the sources disconnected + break; + } + + if (_Index >= std::tr1::tuple_size<_Type>::value) + { + // More sources that we expect + break; + } + + _Sources[_Index] = _PSource; + _Index++; + ++_Iter; + } + + // The order nodes should not have unlinked while the join node is + // active. + + if (_Index != std::tr1::tuple_size<_Type>::value) + { + // On debug build assert to help debugging + _CONCRT_ASSERT(_Index == std::tr1::tuple_size<_Type>::value); + return false; + } + + bool _IsAcquireSuccessful = _Try_consume_source_messages<0>(_Destination_tuple, _Sources); + + return _IsAcquireSuccessful; + } + + /// <summary> + /// Propagate messages in priority order + /// </summary> + /// <param name="_MessageBuffer"> + /// Reference to a message queue with messages to be propagated + /// </param> + /**/ + void _Propagate_priority_order(::Concurrency::details::_Queue<message<_Target_type>> & _MessageBuffer) + { + message<_Target_type> * _Msg = _MessageBuffer._Peek(); + + // If someone has reserved the _Head message, don't propagate anymore + if (_M_pReservedFor != NULL) + { + return; + } + + while (_Msg != NULL) + { + message_status _Status = declined; + + // Always start from the first target that linked + for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Target_type> * _PTarget = *_Iter; + _Status = _PTarget->propagate(_Msg, this); + + // Ownership of message changed. Do not propagate this + // message to any other target. + if (_Status == accepted) + { + break; + } + + // If the target just propagated to reserved this message, stop + // propagating it to others + if (_M_pReservedFor != NULL) + { + break; + } + } + + // If status is anything other than accepted, then the head message + // was not propagated out. Thus, nothing after it in the queue can + // be propagated out. Cease propagation. + if (_Status != accepted) + { + break; + } + + // Get the next message + _Msg = _MessageBuffer._Peek(); + } + } + + /// <summary> + /// Called when all the source messaging blocks have received their messages. The payloads are copied + /// into local tuple and then packaged into a message to be propagated: _M_pSendMessage. + /// </summary> + /**/ + message<_Destination_type> * _Create_send_message() + { + _Destination_type _Destination_tuple; + + // Populate the sources buffer + ISource<size_t> * _Sources[std::tr1::tuple_size<_Type>::value]; + size_t _Index = 0; + + // Get an iterator which will keep a reference on the connected sources + source_iterator _Iter = _M_connectedSources.begin(); + + while (*_Iter != NULL) + { + ISource<size_t> * _PSource = *_Iter; + + if (_PSource == NULL) + { + // One of the sources disconnected + break; + } + + // Avoid buffer overrun + if (_Index >= std::tr1::tuple_size<_Type>::value) + { + // More sources that we expect + break; + } + + _Sources[_Index] = *_Iter; + _Index++; + ++_Iter; + } + + // The order nodes should not have unlinked while the join node is + // active. + if (_Index != std::tr1::tuple_size<_Type>::value) + { + // On debug build assert to help debugging + _CONCRT_ASSERT(_Index == std::tr1::tuple_size<_Type>::value); + return NULL; + } + + _Populate_destination_tuple<0>(_Destination_tuple, _Sources); + + return new message<_Destination_type>(_Destination_tuple); + } + + /// <summary> + /// Deletes all messages currently stored in this message block. Should be called + /// by the destructor to ensure any messages propagated in are cleaned up. + /// </summary> + /**/ + void _Delete_stored_messages() + { + // Delete any messages remaining in the output queue + for (;;) + { + message<_Destination_type> * _Msg = _M_messageBuffer._Dequeue(); + if (_Msg == NULL) + { + break; + } + delete _Msg; + } + } + + /// <summary> + /// Copies payloads from all sources to destination tuple. + /// </summary> + /**/ + template<int _Index> + void _Populate_destination_tuple(_Destination_type & _Destination_tuple, ISource<size_t> ** _Sources) + { + _Order_node_base<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> * _Node = + static_cast<_Order_node_base<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> *>(_Sources[_Index]); + + std::tr1::get<_Index>(_Destination_tuple) = _Node->value(); + _Node->_Reset(); + + _Populate_destination_tuple<_Index + 1>(_Destination_tuple, _Sources); + } + + /// <summary> + /// Provides a sentinel template specialization for _Populate_destination_tuple recursive + /// template expansion. + /// </summary> + /**/ + template<> void _Populate_destination_tuple<std::tr1::tuple_size<_Type>::value>(_Destination_type &, ISource<size_t> **) + { + } + + // A tuple containing a collection of source messaging blocks + _Type _M_sourceTuple; + + // Counts messages received by sources of this node and is used to trigger propagation to targets + // This value starts at the total number of inputs and counts down to zero. When it reaches zero, + // a join of the inputs is started. + volatile long _M_counter; + + // Buffer to hold outgoing messages + ::Concurrency::details::_Queue<message<_Destination_type>> _M_messageBuffer; + +private: + // + // Hide assignment operator and copy constructor + // + _Join_node(const _Join_node & _Join); // no copy constructor + _Join_node const &operator =(_Join_node const &); // no assignment operator +}; + +/// <summary> +/// A <c>multitype_join</c> messaging block is a multi-source, single-target messaging block that +/// combines together messages of different types from each of its sources and offers a tuple +/// of the combined messages to its targets. +/// </summary> +/// <typeparam name="_Type"> +/// The <c>tuple</c> payload type of the messages joined and propagated by the block. +/// </typeparam> +/// <typeparam name="_Jtype"> +/// The kind of <c>join</c> block this is, either <c>greedy</c> or <c>non_greedy</c> +/// </typeparam> +/// <remarks> +/// For more information, see <see cref="Asynchronous Message Blocks"/>. +/// </remarks> +/// <seealso cref="choice Class"/> +/// <seealso cref="join Class"/> +/// <seealso cref="join_type Enumeration"/> +/// <seealso cref="make_join Function"/> +/// <seealso cref="make_greedy_join Function"/> +/// <seealso cref="tuple Class"/> +/**/ +template<typename _Type, join_type _Jtype = non_greedy> +class multitype_join: public ISource<typename _Unwrap<_Type>::type> +{ +public: + + typedef typename _Unwrap<_Type>::type _Destination_type; + + /// <summary> + /// Constructs a <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for this <c>multitype_join</c> messaging block. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + explicit multitype_join(_Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(NULL), _M_pScheduleGroup(NULL) + { + _M_pJoinNode = new _Join_node<_Type, _Destination_type, _Jtype>(); + _Initialize_joins<0>(); + } + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs a <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the propagation task for the <c>multitype_join</c> messaging block is scheduled. + /// </param> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for this <c>multitype_join</c> messaging block. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + multitype_join(Scheduler& _PScheduler, _Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(&_PScheduler), _M_pScheduleGroup(NULL) + { + _M_pJoinNode = new _Join_node<_Type, _Destination_type, _Jtype>(_PScheduler); + _Initialize_joins<0>(); + } + + /// <summary> + /// Constructs a <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_PScheduleGroup"> + /// The <c>ScheduleGroup</c> object within which the propagation task for the <c>multitype_join</c> messaging block is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <param name="_Tuple"> + /// A <c>tuple</c> of sources for this <c>multitype_join</c> messaging block. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + multitype_join(ScheduleGroup& _PScheduleGroup, _Type _Tuple) : _M_sourceTuple(_Tuple), _M_pScheduler(NULL), _M_pScheduleGroup(&_PScheduleGroup) + { + _M_pJoinNode = new _Join_node<_Type, _Destination_type, _Jtype>(_PScheduleGroup); + _Initialize_joins<0>(); + } +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Constructs a <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_Join"> + /// A <c>multitype_join</c> messaging block to copy from. + /// Note that the original object is orphaned, making this a move constructor. + /// </param> + /// <remarks> + /// <para> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PScheduleGroup"/> parameters. + /// </para> + /// <para> + /// Move construction is not performed under a lock, which means that it is up to the user + /// to make sure that there are no light-weight tasks in flight at the time of moving. + /// Otherwise, numerous races can occur, leading to exceptions or inconsistent state. + /// </para> + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + multitype_join(multitype_join && _Join) + { + // Copy scheduler group or scheduler to the new object. + _M_pScheduleGroup = _Join._M_pScheduleGroup; + _M_pScheduler = _Join._M_pScheduler; + + // Single assignment is heap allocated, so simply copy the pointer. If it already has + // a value, it will be preserved. + _M_pJoinNode = _Join._M_pJoinNode; + _Join._M_pJoinNode = NULL; + + // Invoke copy assignment for tuple to copy pointers to message blocks. + _M_sourceTuple = _Join._M_sourceTuple; + + // Copy the pointers to order nodes to a new object and zero out in the old object. + memcpy(_M_pSourceJoins, _Join._M_pSourceJoins, sizeof(_M_pSourceJoins)); + memset(_Join._M_pSourceJoins, 0, sizeof(_M_pSourceJoins)); + } + + /// <summary> + /// Destroys the <c>multitype_join</c> messaging block. + /// </summary> + /**/ + ~multitype_join() + { + delete _M_pJoinNode; + _Delete_joins<0>(); + } + + /// <summary> + /// A type alias for <typeparamref name="_Type"/>. + /// </summary> + /**/ + typedef typename _Type type; + + // + // ISource public function implementations + // + + /// <summary> + /// Links a target block to this <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to link to this <c>multitype_join</c> messaging block. + /// </param> + /**/ + virtual void link_target(_Inout_ ITarget<_Destination_type> * _PTarget) + { + _M_pJoinNode->link_target(_PTarget); + } + + /// <summary> + /// Unlinks a target block from this <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to an <c>ITarget</c> block to unlink from this <c>multitype_join</c> messaging block. + /// </param> + /**/ + virtual void unlink_target(_Inout_ ITarget<_Destination_type> * _PTarget) + { + _M_pJoinNode->unlink_target(_PTarget); + } + + /// <summary> + /// Unlinks all targets from this <c>multitype_join</c> messaging block. + /// </summary> + /**/ + virtual void unlink_targets() + { + _M_pJoinNode->unlink_targets(); + } + + /// <summary> + /// Accepts a message that was offered by this <c>multitype_join</c> block, transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the offered <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>accept</c> method. + /// </param> + /// <returns> + /// A pointer to the message that the caller now has ownership of. + /// </returns> + /**/ + virtual message<_Destination_type> * accept(runtime_object_identity _MsgId, _Inout_ ITarget<_Destination_type> * _PTarget) + { + return _M_pJoinNode->accept(_MsgId, _PTarget); + } + + /// <summary> + /// Reserves a message previously offered by this <c>multitype_join</c> messaging block. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being reserved. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>reserve</c> method. + /// </param> + /// <returns> + /// <c>true</c> if the message was successfully reserved, <c>false</c> otherwise. Reservations can fail + /// for many reasons, including: the message was already reserved or accepted by another target, the source could + /// deny reservations, and so forth. + /// </returns> + /// <remarks> + /// After you call <c>reserve</c>, if it succeeds, you must call either <c>consume</c> or <c>release</c> + /// in order to take or give up possession of the message, respectively. + /// </remarks> + /**/ + virtual bool reserve(runtime_object_identity _MsgId, _Inout_ ITarget<_Destination_type> * _PTarget) + { + return _M_pJoinNode->reserve(_MsgId, _PTarget); + } + + /// <summary> + /// Consumes a message previously offered by the <c>multitype_join</c> messaging block and successfully reserved by the target, + /// transferring ownership to the caller. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the reserved <c>message</c> object. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>consume</c> method. + /// </param> + /// <returns> + /// A pointer to the <c>message</c> object that the caller now has ownership of. + /// </returns> + /// <remarks> + /// The <c>consume</c> method is similar to <c>accept</c>, but must always be preceded by a call to <c>reserve</c> that + /// returned <c>true</c>. + /// </remarks> + /**/ + virtual message<_Destination_type> * consume(runtime_object_identity _MsgId, _Inout_ ITarget<_Destination_type> * _PTarget) + { + return _M_pJoinNode->consume(_MsgId, _PTarget); + } + + /// <summary> + /// Releases a previous successful message reservation. + /// </summary> + /// <param name="_MsgId"> + /// The <c>runtime_object_identity</c> of the <c>message</c> object being released. + /// </param> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling the <c>release</c> method. + /// </param> + /**/ + virtual void release(runtime_object_identity _MsgId, _Inout_ ITarget<_Destination_type> * _PTarget) + { + _M_pJoinNode->release(_MsgId, _PTarget); + } + + /// <summary> + /// Acquires a reference count on this <c>multitype_join</c> messaging block, to prevent deletion. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being linked to this source + /// during the <c>link_target</c> method. + /// </remarks> + /**/ + virtual void acquire_ref(_Inout_ ITarget<_Destination_type> * _PTarget) + { + _M_pJoinNode->acquire_ref(_PTarget); + } + + /// <summary> + /// Releases a reference count on this <c>multiple_join</c> messaging block. + /// </summary> + /// <param name="_PTarget"> + /// A pointer to the target block that is calling this method. + /// </param> + /// <remarks> + /// This method is called by an <c>ITarget</c> object that is being unlinked from this source. + /// The source block is allowed to release any resources reserved for the target block. + /// </remarks> + /**/ + virtual void release_ref(_Inout_ ITarget<_Destination_type> * _PTarget) + { + _M_pJoinNode->release_ref(_PTarget); + } + +private: + + /// <summary> + /// Constructs and initializes a _Order_node for each tuple messaging block passed in. + /// </summary> + /// <typeparam name="_Index"> + /// The highest-number index of the multitype_join's sources + /// </typeparam> + /**/ + template<int _Index> + void _Initialize_joins() + { + std::tr1::tuple_element<_Index, _Type>::type _Item = std::tr1::get<_Index>(_M_sourceTuple); + _Order_node_base<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> * _Order_node_element = NULL; + + bool fIsNonGreedy = (_Jtype == non_greedy); + + if (fIsNonGreedy) + { + if (_M_pScheduleGroup != NULL) + { + _Order_node_element = new _Non_greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduleGroup, _Item, _Index); + } + else if (_M_pScheduler != NULL) + { + _Order_node_element = new _Non_greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduler, _Item, _Index); + } + else + { + _Order_node_element = new _Non_greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (_Item, _Index); + } + } + else + { + if (_M_pScheduleGroup != NULL) + { + _Order_node_element = new _Greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduleGroup, _Item, _Index); + } + else if (_M_pScheduler != NULL) + { + _Order_node_element = new _Greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (*_M_pScheduler, _Item, _Index); + } + else + { + _Order_node_element = new _Greedy_node<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> (_Item, _Index); + } + } + _M_pSourceJoins[_Index] = _Order_node_element; + _Order_node_element->link_target(_M_pJoinNode); + _Initialize_joins<_Index + 1>(); + } + + /// <summary> + /// Provides a sentinel template specialization for _Initialize_joins recursive + /// template expansion. + /// </summary> + /**/ + template<> void _Initialize_joins<std::tr1::tuple_size<_Type>::value>() + { + } + + /// <summary> + /// Deletes all _Order_node elements that were created in _Initialize_joins. + /// </summary> + /// <typeparam name="_Index"> + /// The highest-number index of the multitype_join's sources + /// </typeparam> + /**/ + template<int _Index> + void _Delete_joins() + { + delete reinterpret_cast<_Order_node_base<std::tr1::remove_pointer<std::tr1::tuple_element<_Index, _Type>::type>::type::source_type> *>(_M_pSourceJoins[_Index]); + _M_pSourceJoins[_Index] = NULL; + _Delete_joins<_Index + 1>(); + } + + /// <summary> + /// Provides a sentinel template specialization for _Delete_joins recursive + /// template expansion. + /// </summary> + /**/ + template<> void _Delete_joins<std::tr1::tuple_size<_Type>::value>() + { + } + + // Array of pointers to _Order_node elements representing each source + void * _M_pSourceJoins[std::tr1::tuple_size<_Type>::value]; + + // Join node that collects source messaging block messages + _Join_node<_Type, _Destination_type, _Jtype> * _M_pJoinNode; + + // Tuple of messaging blocks that are sources to this multitype_join + _Type _M_sourceTuple; + + // The scheduler to propagate messages on + Scheduler * _M_pScheduler; + + // The schedule group to propagate messages on + ScheduleGroup * _M_pScheduleGroup; + +private: + // + // Hide assignment operator + // + multitype_join const &operator =(multitype_join const &); // no assignment operator + multitype_join(multitype_join const &); // no copy constructor +}; + +// Templated factory functions that create a join, three flavors + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +/// <summary> +/// Constructs a <c>non_greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduler"> +/// The <c>Scheduler</c> object within which the propagation task for the <c>multitype_join</c> messaging block is scheduled. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>non_greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/// <seealso cref="Scheduler Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>> +make_join(Scheduler& _PScheduler, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>>(_PScheduler, std::make_tuple(_Item1, _Item2, _Items...)); +} + +/// <summary> +/// Constructs a <c>non_greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduleGroup"> +/// The <c>ScheduleGroup</c> object within which the propagation task for the <c>multitype_join</c> messaging block is scheduled. +/// The <c>Scheduler</c> object used is implied by the schedule group. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>non_greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/// <seealso cref="ScheduleGroup Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>> +make_join(ScheduleGroup& _PScheduleGroup, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>>(_PScheduleGroup, std::make_tuple(_Item1, _Item2, _Items...)); +} + +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + +/// <summary> +/// Constructs a <c>non_greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>non_greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>> +make_join(_Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>>(std::make_tuple(_Item1, _Item2, _Items...)); +} + +// Templated factory functions that create a *greedy* join, three flavors +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +/// <summary> +/// Constructs a <c>greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduler"> +/// The <c>Scheduler</c> object within which the propagation task for the <c>multitype_join</c> messaging block +/// is scheduled. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/// <seealso cref="Scheduler Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy> +make_greedy_join(Scheduler& _PScheduler, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy>(_PScheduler, std::make_tuple(_Item1, _Item2, _Items...)); +} + +/// <summary> +/// Constructs a <c>greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_PScheduleGroup"> +/// The <c>ScheduleGroup</c> object within which the propagation task for the <c>multitype_join</c> messaging block is scheduled. +/// The <c>Scheduler</c> object used is implied by the schedule group. +/// </param> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/// <seealso cref="ScheduleGroup Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy> +make_greedy_join(ScheduleGroup& _PScheduleGroup, _Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy>(_PScheduleGroup, std::make_tuple(_Item1, _Item2, _Items...)); +} + +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + +/// <summary> +/// Constructs a <c>greedy multitype_join</c> messaging block from an optional <c>Scheduler</c> +/// or <c>ScheduleGroup</c> and two or more input sources. +/// </summary> +/// <typeparam name="_Type1"> +/// The message block type of the first source. +/// </typeparam> +/// <typeparam name="_Type2"> +/// The message block type of the second source. +/// </typeparam> +/// <typeparam name="_Types"> +/// The message block types of additional sources. +/// </typeparam> +/// <param name="_Item1"> +/// The first source. +/// </param> +/// <param name="_Item2"> +/// The second source. +/// </param> +/// <param name="_Items"> +/// Additional sources. +/// </param> +/// <returns> +/// A <c>greedy multitype_join</c> message block with two or more input sources. +/// </returns> +/// <seealso cref="multitype_join Class"/> +/**/ +template<typename _Type1, typename _Type2, typename... _Types> +multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy> +make_greedy_join(_Type1 _Item1, _Type2 _Item2, _Types... _Items) +{ + return multitype_join<std::tuple<_Type1, _Type2, _Types...>, greedy>(std::make_tuple(_Item1, _Item2, _Items...)); +} + +//************************************************************************** +// Agents: +//************************************************************************** + +/// <summary> +/// The valid states for an <c>agent</c>. +/// </summary> +/// <remarks> +/// For more information, see <see cref="Asynchronous Agents"/>. +/// </remarks> +/**/ +enum agent_status { + /// <summary> + /// The <c>agent</c> has been created but not started. + /// </summary> + /**/ + agent_created, + /// <summary> + /// The <c>agent</c> has been started, but not entered its <c>run</c> method. + /// </summary> + /**/ + agent_runnable, + /// <summary> + /// The <c>agent</c> has started. + /// </summary> + /**/ + agent_started, + /// <summary> + /// The <c>agent</c> finished without being canceled. + /// </summary> + /**/ + agent_done, + /// <summary> + /// The <c>agent</c> was canceled. + /// </summary> + /**/ + agent_canceled +}; + +/// <summary> +/// A class intended to be used as a base class for all independent agents. It is used to hide +/// state from other agents and interact using message-passing. +/// </summary> +/// <remarks> +/// For more information, see <see cref="Asynchronous Agents"/>. +/// </remarks> +/**/ +class agent +{ +public: + /// <summary> + /// Constructs an agent. + /// </summary> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + _CRTIMP2 agent(); + +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP + /// <summary> + /// Constructs an agent. + /// </summary> + /// <param name="_PScheduler"> + /// The <c>Scheduler</c> object within which the execution task of the agent is scheduled. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + _CRTIMP2 agent(Scheduler& _PScheduler); + + /// <summary> + /// Constructs an agent. + /// </summary> + /// <param name="_PGroup"> + /// The <c>ScheduleGroup</c> object within which the execution task of the agent is scheduled. + /// The <c>Scheduler</c> object used is implied by the schedule group. + /// </param> + /// <remarks> + /// The runtime uses the default scheduler if you do not specify the <paramref name="_PScheduler"/> + /// or <paramref name="_PGroup"/> parameters. + /// </remarks> + /// <seealso cref="Scheduler Class"/> + /// <seealso cref="ScheduleGroup Class"/> + /**/ + _CRTIMP2 agent(ScheduleGroup& _PGroup); +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + + /// <summary> + /// Destroys the agent. + /// </summary> + /// <remarks> + /// It is an error to destroy an agent that is not in a terminal state (either <c>agent_done</c> or + /// <c>agent_canceled</c>). This can be avoided by waiting for the agent to reach a terminal state + /// in the destructor of a class that inherits from the <c>agent</c> class. + /// </remarks> + /**/ + _CRTIMP2 virtual ~agent(); + + /// <summary> + /// An asynchronous source of status information from the agent. + /// </summary> + /// <returns> + /// Returns a message source that can send messages about the current state of the agent. + /// </returns> + /**/ + _CRTIMP2 ISource<agent_status> * status_port(); + + /// <summary> + /// A synchronous source of status information from the agent. + /// </summary> + /// <returns> + /// Returns the current state of the agent. Note that this returned state could change + /// immediately after being returned. + /// </returns> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 agent_status status(); + + /// <summary> + /// Moves an agent from the <c>agent_created</c> state to the <c>agent_runnable</c> state, and schedules it for execution. + /// </summary> + /// <returns> + /// <c>true</c> if the agent started correctly, <c>false</c> otherwise. An agent that has been canceled cannot be started. + /// </returns> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 bool start(); + + /// <summary> + /// Moves an agent from either the <c>agent_created</c> or <c>agent_runnable</c> states to the <c>agent_canceled</c> state. + /// </summary> + /// <returns> + /// <c>true</c> if the agent was canceled, <c>false</c> otherwise. An agent cannot be canceled if it has already started + /// running or has already completed. + /// </returns> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 bool cancel(); + + /// <summary> + /// Waits for an agent to complete its task. + /// </summary> + /// <param name="_PAgent"> + /// A pointer to the agent to wait for. + /// </param> + /// <param name="_Timeout"> + /// The maximum time for which to wait, in milliseconds. + /// </param> + /// <returns> + /// The <c>agent_status</c> of the agent when the wait completes. This can either be <c>agent_canceled</c> + /// or <c>agent_done</c>. + /// </returns> + /// <remarks> + /// An agent task is completed when the agent enters the <c>agent_canceled</c> or <c>agent_done</c> states. + /// <para>If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, + /// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount + /// of time expires before the agent has completed its task.</para> + /// </remarks> + /// <seealso cref="agent::wait_for_all Method"/> + /// <seealso cref="agent::wait_for_one Method"/> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 static agent_status __cdecl wait(_Inout_ agent * _PAgent, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE); + + /// <summary> + /// Waits for all of the specified agents to complete their tasks. + /// </summary> + /// <param name="_Count"> + /// The number of agent pointers present in the array <paramref name="_PAgents"/>. + /// </param> + /// <param name="_PAgents"> + /// An array of pointers to the agents to wait for. + /// </param> + /// <param name="_PStatus"> + /// A pointer to an array of agent statuses. Each status value will represent the status of the corresponding + /// agent when the method returns. + /// </param> + /// <param name="_Timeout"> + /// The maximum time for which to wait, in milliseconds. + /// </param> + /// <remarks> + /// An agent task is completed when the agent enters the <c>agent_canceled</c> or <c>agent_done</c> states. + /// <para>If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, + /// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount + /// of time expires before the agent has completed its task.</para> + /// </remarks> + /// <seealso cref="agent::wait Method"/> + /// <seealso cref="agent::wait_for_one Method"/> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 static void __cdecl wait_for_all(size_t _Count, _In_reads_(_Count) agent ** _PAgents, + _Out_writes_opt_(_Count) agent_status * _PStatus = NULL, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE); + + /// <summary> + /// Waits for any one of the specified agents to complete its task. + /// </summary> + /// <param name="_Count"> + /// The number of agent pointers present in the array <paramref name="_PAgents"/>. + /// </param> + /// <param name="_PAgents"> + /// An array of pointers to the agents to wait for. + /// </param> + /// <param name="_Status"> + /// A reference to a variable where the agent status will be placed. + /// </param> + /// <param name="_Index"> + /// A reference to a variable where the agent index will be placed. + /// </param> + /// <param name="_Timeout"> + /// The maximum time for which to wait, in milliseconds. + /// </param> + /// <remarks> + /// An agent task is completed when the agent enters the <c>agent_canceled</c> or <c>agent_done</c> states. + /// <para>If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, + /// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount + /// of time expires before the agent has completed its task.</para> + /// </remarks> + /// <seealso cref="agent::wait Method"/> + /// <seealso cref="agent::wait_for_all Method"/> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 static void __cdecl wait_for_one(size_t _Count, _In_reads_(_Count) agent ** _PAgents, agent_status& _Status, + size_t& _Index, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE); + +protected: + /// <summary> + /// Represents the main task of an agent. <c>run</c> should be overridden in a derived class, and specifies what + /// the agent should do after it has been started. + /// </summary> + /// <remarks> + /// The agent status is changed to <c>agent_started</c> right before this method is invoked. The method should + /// invoke <c>done</c> on the agent with an appropriate status before returning, and may not throw any + /// exceptions. + /// </remarks> + /**/ + virtual void run() = 0; + + /// <summary> + /// Moves an agent into the <c>agent_done</c> state, indicating that the agent has completed. + /// </summary> + /// <returns> + /// <c>true</c> if the agent is moved to the <c>agent_done</c> state, <c>false</c> otherwise. An agent that has + /// been canceled cannot be moved to the <c>agent_done</c> state. + /// </returns> + /// <remarks> + /// This method should be called at the end of the <c>run</c> method, when you know the execution of your agent + /// has completed. + /// </remarks> + /// <seealso cref="agent_status Enumeration"/> + /**/ + _CRTIMP2 bool done(); + + /// <summary> + /// Holds the current status of the agent. + /// </summary> + /**/ + overwrite_buffer<agent_status> _M_status; + +private: + + // A flag to check of whether the agent can be started + // This is initialized to TRUE and there is a race between Start() and Cancel() to set it + // to FALSE. Once Started or Canceled, further calls to Start() or Cancel() will return false. + /**/ + volatile long _M_fStartable; + + // A flag to check of whether the agent can be canceled + // This is initailized to TRUE and there is a race between Cancel() and the LWT executing + // a task that has been started to set it to FALSE. If Cancel() wins, the task will not be + // executed. If the LWT wins, Cancel() will return false. + /**/ + volatile long _M_fCancelable; + + // A static wrapper function that calls the Run() method. Used for scheduling of the task + /**/ + static void __cdecl _Agent_task_wrapper(void * data); + + Scheduler * _M_pScheduler; + ScheduleGroup * _M_pScheduleGroup; + + // + // Hide assignment operator and copy constructor + // + agent const &operator =(agent const&); // no assignment operator + agent(agent const &); // no copy constructor +}; + +//************************************************************************** +// Direct Messaging APIs: +//************************************************************************** + +/// <summary> +/// A general receive implementation, allowing a context to wait for data from +/// exactly one source and filter the values that are accepted. If the specified timeout is not +/// COOPERATIVE_TIMEOUT_INFINITE, an exception (operation_timed_out) will be thrown if the specified amount +/// of time expires before a message is received. Note that zero length timeouts should likely use +/// try_receive as opposed to receive with a timeout of zero as it is more efficient and does not +/// throw exceptions on timeouts. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/// <param name="_Src"> +/// A pointer to the source from which data is expected. +/// </param> +/// <param name="_Timeout"> +/// The maximum time for which the method should for the data, in milliseconds. +/// </param> +/// <param name="_Filter_proc"> +/// A pointer to a filter which will indicate whether to accept the data or not. +/// </param> +/// <returns> +/// A value from the source, of the payload type. +/// </returns> +/**/ +template <class _Type> +_Type _Receive_impl(ISource<_Type> * _Src, unsigned int _Timeout, typename ITarget<_Type>::filter_method const* _Filter_proc) +{ + // The Blocking Recipient messaging block class is internal to the receive function + class _Blocking_recipient : public ITarget<_Type> + { + public: + // Create an Blocking Recipient + _Blocking_recipient(ISource<_Type> * _PSource, + unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) : + _M_pFilter(NULL), _M_pConnectedTo(NULL), _M_pMessage(NULL), _M_fState(_NotInitialized), _M_timeout(_Timeout) + { + _Connect(_PSource); + } + + // Create an Blocking Recipient + _Blocking_recipient(ISource<_Type> * _PSource, + filter_method const& _Filter, + unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) : + _M_pFilter(NULL), _M_pConnectedTo(NULL), _M_pMessage(NULL), _M_fState(_NotInitialized), _M_timeout(_Timeout) + { + if (_Filter != NULL) + { + _M_pFilter = new filter_method(_Filter); + } + + _Connect(_PSource); + } + + // Cleans up any resources that may have been created by the BlockingRecipient. + ~_Blocking_recipient() + { + _Disconnect(); + + delete _M_pFilter; + delete _M_pMessage; + } + + // Gets the value of the message sent to this BlockingRecipient. Blocks by + // spinning until a message has arrived. + _Type _Value() + { + _Wait_for_message(); + + return _M_pMessage->payload; + } + + // The main propagation function for ITarget blocks. Called by a source + // block, generally within an asynchronous task to send messages to its targets. + virtual message_status propagate(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + // Throw exception if the message being propagated to this block is NULL + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + // Reject if the recipient has already received a message + if (_M_fState == _Initialized) + { + return declined; + } + + // Reject if the message does not meet the filter requirements + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + // Accept the message + _CONCRT_ASSERT(_PSource != NULL); + _M_pMessage = _PSource->accept(_PMessage->msg_id(), this); + + if (_M_pMessage != NULL) + { + // Set the initialized flag on this block + if (_InterlockedExchange(&_M_fState, _Initialized) == _Blocked) + { + _M_ev.set(); + } + + return accepted; + } + + return missed; + } + + // Synchronously sends a message to this block. When this function completes the message will + // already have propagated into the block. + virtual message_status send(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + // Only the connected source is allowed to send messages + // to the blocking recepient. Decline messages without + // a source. + + return declined; + } + + private: + + // Link a source block + virtual void link_source(ISource<_Type> * _PSrc) + { + _M_pConnectedTo = _PSrc; + _PSrc->acquire_ref(this); + } + + // Remove a source messaging block for this BlockingRecipient + virtual void unlink_source(ISource<_Type> * _PSource) + { + if (_InterlockedCompareExchangePointer(reinterpret_cast<void *volatile *>(&_M_pConnectedTo), (void *)NULL, _PSource) == _PSource) + { + _PSource->release_ref(this); + } + } + + // Remove the source messaging block for this BlockingRecipient + virtual void unlink_sources() + { + ISource<_Type> * _PSource = reinterpret_cast<ISource<_Type> *>(_InterlockedExchangePointer(reinterpret_cast<void *volatile *>(&_M_pConnectedTo), (void *)NULL)); + if (_PSource != NULL) + { + _PSource->unlink_target(this); + _PSource->release_ref(this); + } + } + + + // Connect the blocking recipient to the source + void _Connect(ISource<_Type> * _PSource) + { + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + _PSource->link_target(this); + } + + // Cleanup the connection to the blocking recipient's source. There is no need + // to do anything about the associated context. + void _Disconnect() + { + unlink_sources(); + } + + // Internal function used to block while waiting for a message to arrive + // at this BlockingRecipient + void _Wait_for_message() + { + bool _Timeout = false; + + // If we haven't received a message yet, cooperatively block. + if (_InterlockedCompareExchange(&_M_fState, _Blocked, _NotInitialized) == _NotInitialized) + { + if (_M_ev.wait(_M_timeout) == COOPERATIVE_WAIT_TIMEOUT) + { + _Timeout = true; + } + } + + // Unlinking from our source guarantees that there are no threads in propagate + _Disconnect(); + + if (_M_fState != _Initialized) + { + // We had to have timed out if we came out of the wait + // without being initialized. + _CONCRT_ASSERT(_Timeout); + + throw operation_timed_out(); + } + } + + // States for this block + enum + { + _NotInitialized, + _Blocked, + _Initialized + }; + + volatile long _M_fState; + + // The source messaging block connected to this Recipient + ISource<_Type> * _M_pConnectedTo; + + // The message that was received + message<_Type> * volatile _M_pMessage; + + // The timeout. + unsigned int _M_timeout; + + // The event we wait upon + event _M_ev; + + // The filter that is called on this block before accepting a message + filter_method * _M_pFilter; + }; + + if (_Filter_proc != NULL) + { + _Blocking_recipient _Recipient(_Src, *_Filter_proc, _Timeout); + return _Recipient._Value(); + } + else + { + _Blocking_recipient _Recipient(_Src, _Timeout); + return _Recipient._Value(); + } +} + +/// <summary> +/// A general receive implementation, allowing a context to wait for data from +/// exactly one source and filter the values that are accepted. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_Timeout"> +/// The maximum time for which the method should for the data, in milliseconds. +/// </param> +/// <returns> +/// A value from the source, of the payload type. +/// </returns> +/// <remarks> +/// If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, +/// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount +/// of time expires before a message is received. If you want a zero length timeout, you should use the +/// <see cref="try_receive Function">try_receive</see> function, as opposed to calling <c>receive</c> with a timeout +/// of <c>0</c> (zero), as it is more efficient and does not throw exceptions on timeouts. +/// <para>For more information, see <see cref="Message Passing Functions"/>.</para> +/// </remarks> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +_Type receive(_Inout_ ISource<_Type> * _Src, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) +{ + return _Receive_impl(_Src, _Timeout, NULL); +} + +/// <summary> +/// A general receive implementation, allowing a context to wait for data from +/// exactly one source and filter the values that are accepted. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_Filter_proc"> +/// A filter function which determines whether messages should be accepted. +/// </param> +/// <param name="_Timeout"> +/// The maximum time for which the method should for the data, in milliseconds. +/// </param> +/// <returns> +/// A value from the source, of the payload type. +/// </returns> +/// <remarks> +/// If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, +/// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount +/// of time expires before a message is received. If you want a zero length timeout, you should use the +/// <see cref="try_receive Function">try_receive</see> function, as opposed to calling <c>receive</c> with a timeout +/// of <c>0</c> (zero), as it is more efficient and does not throw exceptions on timeouts. +/// <para>For more information, see <see cref="Message Passing Functions"/>.</para> +/// </remarks> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +_Type receive(_Inout_ ISource<_Type> * _Src, typename ITarget<_Type>::filter_method const& _Filter_proc, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) +{ + return _Receive_impl(_Src, _Timeout, &_Filter_proc); +} + +/// <summary> +/// A general receive implementation, allowing a context to wait for data from +/// exactly one source and filter the values that are accepted. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_Timeout"> +/// The maximum time for which the method should for the data, in milliseconds. +/// </param> +/// <returns> +/// A value from the source, of the payload type. +/// </returns> +/// <remarks> +/// If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, +/// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount +/// of time expires before a message is received. If you want a zero length timeout, you should use the +/// <see cref="try_receive Function">try_receive</see> function, as opposed to calling <c>receive</c> with a timeout +/// of <c>0</c> (zero), as it is more efficient and does not throw exceptions on timeouts. +/// <para>For more information, see <see cref="Message Passing Functions"/>.</para> +/// </remarks> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +_Type receive(ISource<_Type> &_Src, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) +{ + return _Receive_impl(&_Src, _Timeout, NULL); +} + +/// <summary> +/// A general receive implementation, allowing a context to wait for data from +/// exactly one source and filter the values that are accepted. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_Filter_proc"> +/// A filter function which determines whether messages should be accepted. +/// </param> +/// <param name="_Timeout"> +/// The maximum time for which the method should for the data, in milliseconds. +/// </param> +/// <returns> +/// A value from the source, of the payload type. +/// </returns> +/// <remarks> +/// If the parameter <paramref name="_Timeout"/> has a value other than the constant <c>COOPERATIVE_TIMEOUT_INFINITE</c>, +/// the exception <see cref="operation_timed_out Class">operation_timed_out</see> is thrown if the specified amount +/// of time expires before a message is received. If you want a zero length timeout, you should use the +/// <see cref="try_receive Function">try_receive</see> function, as opposed to calling <c>receive</c> with a timeout +/// of <c>0</c> (zero), as it is more efficient and does not throw exceptions on timeouts. +/// <para>For more information, see <see cref="Message Passing Functions"/>.</para> +/// </remarks> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +_Type receive(ISource<_Type> &_Src, typename ITarget<_Type>::filter_method const& _Filter_proc, unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE) +{ + return _Receive_impl(&_Src, _Timeout, &_Filter_proc); +} + +/// <summary> +/// Helper function that implements try_receive +/// A general try-receive implementation, allowing a context to look for data from +/// exactly one source and filter the values that are accepted. If the data is not +/// ready, try_receive will return false. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/// <param name="_Src"> +/// A pointer to the source from which data is expected. +/// </param> +/// <param name="_value"> +/// A reference to a location where the result will be placed. +/// </param> +/// <param name="_Filter_proc"> +/// A pointer to a filter which will indicate whether to accept the data or not. +/// </param> +/// <returns> +/// A bool indicating whether a payload was placed in <paramref name="_value"/> or not. +/// </returns> +/**/ +template <class _Type> +bool _Try_receive_impl(ISource<_Type> * _Src, _Type & _value, typename ITarget<_Type>::filter_method const * _Filter_proc) +{ + // The Immediate Recipient messaging block class is internal to the receive function + class _Immediate_recipient : public ITarget<_Type> + { + public: + // Create an Immediate Recipient + _Immediate_recipient(ISource<_Type> * _PSource) : + _M_pFilter(NULL), _M_pConnectedTo(NULL), _M_pMessage(NULL), _M_isInitialized(0) + { + _Connect(_PSource); + } + + // Create an Immediate Recipient + _Immediate_recipient(ISource<_Type> * _PSource, + filter_method const& _Filter) : + _M_pFilter(NULL), _M_pConnectedTo(NULL), _M_pMessage(NULL), _M_isInitialized(0) + { + if (_Filter != NULL) + { + _M_pFilter = new filter_method(_Filter); + } + + _Connect(_PSource); + } + + // Cleans up any resources that may have been created by the ImmediateRecipient. + ~_Immediate_recipient() + { + _Disconnect(); + + delete _M_pFilter; + delete _M_pMessage; + } + + // Gets the value of the message sent to this ImmediateRecipient. + bool _Value(_Type & _value) + { + // Unlinking from our source guarantees that there are no threads in propagate + _Disconnect(); + + if (_M_pMessage != NULL) + { + _value = _M_pMessage->payload; + return true; + } + + return false; + } + + // The main propagation function for ITarget blocks. Called by a source + // block, generally within an asynchronous task to send messages to its targets. + virtual message_status propagate(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + message_status _Result = accepted; + + // Throw exception if the message being propagated to this block is NULL + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + // Reject if the recipient has already received a message + if (_M_isInitialized == 1) + { + return declined; + } + + // Reject if the message does not meet the filter requirements + if (_M_pFilter != NULL && !(*_M_pFilter)(_PMessage->payload)) + { + return declined; + } + + // Accept the message + _CONCRT_ASSERT(_PSource != NULL); + _M_pMessage = _PSource->accept(_PMessage->msg_id(), this); + + // Set the initialized flag on this block + + if (_M_pMessage != NULL) + { + // Fence to ensure that the above update to _M_pMessage is visible + _InterlockedExchange(&_M_isInitialized, 1); + _Result = accepted; + } + else + { + _Result = missed; + } + + return _Result; + } + + + // Synchronously sends a message to this block. When this function completes the message will + // already have propagated into the block. + virtual message_status send(message<_Type> * _PMessage, ISource<_Type> * _PSource) + { + if (_PMessage == NULL) + { + throw std::invalid_argument("_PMessage"); + } + + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + // Only the connected source is allowed to send messages + // to the blocking recepient. Decline messages without + // a source. + + return declined; + } + + private: + + // Add a source messaging block + virtual void link_source(ISource<_Type> * _PSrc) + { + _M_pConnectedTo = _PSrc; + _PSrc->acquire_ref(this); + } + + // Remove a source messaging block for this BlockingRecipient + virtual void unlink_source(ISource<_Type> * _PSource) + { + if (_InterlockedCompareExchangePointer(reinterpret_cast<void *volatile *>(&_M_pConnectedTo), (void *)NULL, _PSource) == _PSource) + { + _PSource->release_ref(this); + } + } + + // Remove the source messaging block for this BlockingRecipient + virtual void unlink_sources() + { + ISource<_Type> * _PSource = reinterpret_cast<ISource<_Type> *>(_InterlockedExchangePointer(reinterpret_cast<void *volatile *>(&_M_pConnectedTo), (void *)NULL)); + if (_PSource != NULL) + { + _PSource->unlink_target(this); + _PSource->release_ref(this); + } + } + + // Connect to a source block + void _Connect(ISource<_Type> * _PSource) + { + if (_PSource == NULL) + { + throw std::invalid_argument("_PSource"); + } + + _CONCRT_ASSERT(_M_isInitialized == 0); + + _PSource->link_target(this); + } + + // + // Cleanup the connection to the trigger's source. There is no need + // to do anything about the associated context. + // + void _Disconnect() + { + unlink_sources(); + } + + // The source messaging block connected to this Recipient + ISource<_Type> * _M_pConnectedTo; + + // The message that was received + message<_Type> * volatile _M_pMessage; + + // A flag for whether or not this block has been initialized with a value + volatile long _M_isInitialized; + + // The filter that is called on this block before accepting a message + filter_method * _M_pFilter; + }; + + if (_Filter_proc != NULL) + { + _Immediate_recipient _Recipient(_Src, *_Filter_proc); + return _Recipient._Value(_value); + } + else + { + _Immediate_recipient _Recipient(_Src); + return _Recipient._Value(_value); + } +} + +/// <summary> +/// A general try-receive implementation, allowing a context to look for data from +/// exactly one source and filter the values that are accepted. If the data is not +/// ready, the method will return false. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_value"> +/// A reference to a location where the result will be placed. +/// </param> +/// <returns> +/// A <c>bool</c> value indicating whether or not a payload was placed in <paramref name="_value"/>. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool try_receive(_Inout_ ISource<_Type> * _Src, _Type & _value) +{ + return _Try_receive_impl(_Src, _value, NULL); +} + +/// <summary> +/// A general try-receive implementation, allowing a context to look for data from +/// exactly one source and filter the values that are accepted. If the data is not +/// ready, the method will return false. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_value"> +/// A reference to a location where the result will be placed. +/// </param> +/// <param name="_Filter_proc"> +/// A filter function which determines whether messages should be accepted. +/// </param> +/// <returns> +/// A <c>bool</c> value indicating whether or not a payload was placed in <paramref name="_value"/>. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool try_receive(_Inout_ ISource<_Type> * _Src, _Type & _value, typename ITarget<_Type>::filter_method const& _Filter_proc) +{ + return _Try_receive_impl(_Src, _value, &_Filter_proc); +} + +/// <summary> +/// A general try-receive implementation, allowing a context to look for data from +/// exactly one source and filter the values that are accepted. If the data is not +/// ready, the method will return false. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_value"> +/// A reference to a location where the result will be placed. +/// </param> +/// <returns> +/// A <c>bool</c> value indicating whether or not a payload was placed in <paramref name="_value"/>. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool try_receive(ISource<_Type> & _Src, _Type & _value) +{ + return _Try_receive_impl(&_Src, _value, NULL); +} + +/// <summary> +/// A general try-receive implementation, allowing a context to look for data from +/// exactly one source and filter the values that are accepted. If the data is not +/// ready, the method will return false. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type +/// </typeparam> +/// <param name="_Src"> +/// A pointer or reference to the source from which data is expected. +/// </param> +/// <param name="_value"> +/// A reference to a location where the result will be placed. +/// </param> +/// <param name="_Filter_proc"> +/// A filter function which determines whether messages should be accepted. +/// </param> +/// <returns> +/// A <c>bool</c> value indicating whether or not a payload was placed in <paramref name="_value"/>. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="send Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool try_receive(ISource<_Type> & _Src, _Type & _value, typename ITarget<_Type>::filter_method const& _Filter_proc) +{ + return _Try_receive_impl(&_Src, _value, &_Filter_proc); +} + +namespace details +{ + //************************************************************************** + // Supporting blocks for send and asend + //************************************************************************** + + // Originator block that pushes messages to a target + template <class _Type> + class _AnonymousOriginator : public ISource<_Type> + { + public: + + typedef single_link_registry<ITarget<_Type>> _Target_registry; + + // Create an Originator + _AnonymousOriginator() : _M_pMessage(NULL), _M_pTarget(NULL) + { + } + + // Cleans up any resources that may have been created by the Originator. + virtual ~_AnonymousOriginator() + { + delete _M_pMessage; + } + + // Removes a target messaging block for this Originator + virtual void unlink_target(ITarget<_Type> * _PTarget) + { + throw invalid_operation("unlink_target is not supported on _AnonymousOriginator"); + } + + // Removes the target messaging block from this Originator + virtual void unlink_targets() + { + throw invalid_operation("unlink_targets is not supported on _AnonymousOriginator"); + } + + // Accept on this Originator is called by a target to take ownership of a + // propagated message + virtual message<_Type> * accept(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget != _M_pTarget) + { + return NULL; + } + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return NULL; + } + + // The IDs match, actaully transfer ownership of the message and + // unlink away from the target + message<_Type> * _Result = _M_pMessage; + + // The ownership of this message has changed. Set the internal pointer to NULL + // so it won't be deleted in the destructor + _M_pMessage = NULL; + + return _Result; + } + + // Reserve shall not be called by blocks that supports push + virtual bool reserve(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + throw invalid_operation("reserve is not supported on _AnonymousOriginator"); + } + + // Consume shall not be called by blocks that supports push + virtual message<_Type> * consume(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + throw invalid_operation("consume is not supported on _AnonymousOriginator"); + } + + // Release needs to be defined for ISource blocks, but Originator doesn't need to + // do anything for reservation release because there can only be one target block to read + // the data at a later time. + virtual void release(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + throw invalid_operation("release is not supported on _AnonymousOriginator"); + } + + virtual void acquire_ref(_Inout_ ITarget<_Type> *) + { + throw invalid_operation("acquire_ref is not supported on _AnonymousOriginator"); + } + + virtual void release_ref(_Inout_ ITarget<_Type> *) + { + throw invalid_operation("release_ref is not supported on _AnonymousOriginator"); + } + + private: + friend class _Originator; + + // Send the given value to the target + bool _internal_send(ITarget<_Type> * _PTarget, _Type const & _Value) + { + _M_pTarget = _PTarget; + + _CONCRT_ASSERT(_M_pTarget != NULL); + _CONCRT_ASSERT(_M_pTarget->supports_anonymous_source()); + + // Create the message + message_status _Status = declined; + message<_Type> * _Msg = new message<_Type>(_Value); + + _CONCRT_ASSERT(_M_pMessage == NULL); + _M_pMessage = _Msg; + + // Send the message + _Status = _M_pTarget->send(_M_pMessage, this); + + // If the message is declined, the destructor will + // delete the message + + // status should not be postponed. + _CONCRT_ASSERT(_Status != postponed); + return (_Status == accepted); + } + + bool _internal_asend(ITarget<_Type> * _PTarget, _Type const & _Value) + { + _M_pTarget = _PTarget; + + _CONCRT_ASSERT(_M_pTarget != NULL); + _CONCRT_ASSERT(_M_pTarget->supports_anonymous_source()); + + // Create the message + message_status _Status = declined; + message<_Type> * _Msg = new message<_Type>(_Value); + + _CONCRT_ASSERT(_M_pMessage == NULL); + _M_pMessage = _Msg; + + // Send the message + _Status = _M_pTarget->propagate(_M_pMessage, this); + + // If the message is declined, the destructor will + // delete the message + + // status should not be postponed. + if (_Status == postponed) + { + throw invalid_operation("Messages offered by _AnonymousOriginator shall not be postponed"); + } + + return (_Status == accepted); + } + + // Add a target messaging block for this Originator + virtual void link_target(ITarget<_Type> * _PTarget) + { + throw invalid_operation("link_target is not supported on _AnonymousOriginator"); + } + + // The message that will be propagated by the Originator + message<_Type> * _M_pMessage; + + // The single target for this block + ITarget<_Type> * _M_pTarget; + }; + + // The Originator messaging block class is internal to the send function. + template <class _Type> + class _SyncOriginator : public ISource<_Type> + { + public: + + typedef single_link_registry<ITarget<_Type>> _Target_registry; + + // Create an Originator + _SyncOriginator() : + _M_pMessage(NULL), + _M_fStatus(postponed), + _M_referenceCount(0) + { + } + + // Cleans up any resources that may have been created by the Originator. + virtual ~_SyncOriginator() + { + unlink_targets(); + + _Wait_on_ref(); + + delete _M_pMessage; + } + + // Removes a target messaging block for this Originator + virtual void unlink_target(ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + if (_M_connectedTargets.remove(_PTarget)) + { + _Invoke_unlink_source(_PTarget); + + // Indicate that the send is complete + _Done(declined); + } + } + } + + // Removes the target messaging block from this Originator + virtual void unlink_targets() + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + + for (_Target_registry::iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter) + { + ITarget<_Type> * _PTarget = *_Iter; + if (_M_connectedTargets.remove(_PTarget)) + { + _Invoke_unlink_source(_PTarget); + } + } + + // All targets should be unlinked + _CONCRT_ASSERT(_M_connectedTargets.count() == 0); + + // Indicate that the send is complete + _Done(declined); + } + + // Accept on this Originator is called by a target to take ownership of a + // propagated message + virtual message<_Type> * accept(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + return NULL; + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + return NULL; + } + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return NULL; + } + + // The IDs match, actaully transfer ownership of the message and + // unlink away from the target + message<_Type> * _Result = _M_pMessage; + + // The ownership of this message has changed. Set the internal pointer to NULL + // so it won't be deleted in the destructor + _M_pMessage = NULL; + + // The message has been accepted/consumed, propagate indication that it has succeeded + _Done(accepted); + + return _Result; + } + + // Reserve needs to be defined for ISource blocks, but Originator doesn't need to + // do anything for reservation because there can only be one target block to read + // the data at a later time. + virtual bool reserve(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + return false; + } + + if (_M_pMessage->msg_id() != _MsgId) + { + return false; + } + + return true; + } + + // Consume is called by a target messaging block to take ownership of a + // previously reserved message. + virtual message<_Type> * consume(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + throw bad_target(); + } + + return accept(_MsgId, _PTarget); + } + + // Release needs to be defined for ISource blocks, but Originator doesn't need to + // do anything for reservation release because there can only be one target block to read + // the data at a later time. + virtual void release(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + throw bad_target(); + } + + if ((_M_pMessage == NULL) || (_M_pMessage->msg_id() != _MsgId)) + { + throw message_not_found(); + } + + // If the previously reserved message is released, then propagate + // declined to indicate that the message was not accepted. + _Done(declined); + } + + virtual void acquire_ref(_Inout_ ITarget<_Type> *) + { + _InterlockedIncrement(&_M_referenceCount); + } + + virtual void release_ref(_Inout_ ITarget<_Type> *) + { + _InterlockedDecrement(&_M_referenceCount); + } + + private: + + friend class _Originator; + + // Send the given value to the target + bool _internal_send(ITarget<_Type> * _PTarget, _Type const & _Value) + { + // _send should only be called once. + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + message_status _Status = declined; + message<_Type> * _Msg = new message<_Type>(_Value); + + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + + // link to the target, create a message and send it + link_target(_PTarget); + + _CONCRT_ASSERT(_M_pMessage == NULL); + _M_pMessage = _Msg; + + // Send the message synchronously to the target + _Status = _PTarget->send(_M_pMessage, this); + } + + if (_Status == postponed) + { + // If the target postponed the message, wait for it to + // be accepted/declined. + _Wait_for_completion(); + + // Procure the final status + _Status = _M_fStatus; + } + + // status should not be postponed. + _CONCRT_ASSERT(_Status != postponed); + + return (_Status == accepted); + } + + // Add a target messaging block for this Originator + virtual void link_target(ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + _M_connectedTargets.add(_PTarget); + _Invoke_link_source(_PTarget); + + // There should be no pending messages to propagate at this time. + _CONCRT_ASSERT(_M_pMessage == NULL); + } + + // Wait for the status to reach one of the terminal + // states (!= postponed) + void _Wait_for_completion() + { + // Wait for the event to be signalled + _M_ev.wait(COOPERATIVE_TIMEOUT_INFINITE); + _CONCRT_ASSERT(_M_fStatus != postponed); + + } + + void _Wait_on_ref() + { + ::Concurrency::details::_SpinWaitBackoffNone spinWait; + while(_M_referenceCount != 0) + { + spinWait._SpinOnce(); + } + } + + // Indicate that the send operation has completed + void _Done(message_status _Status) + { + // postponed is not a done state + _CONCRT_ASSERT(_Status != postponed); + + _M_fStatus = _Status; + _M_ev.set(); + } + + // The message that will be propagated by the Originator + message<_Type> * _M_pMessage; + + // Event to indicate completion + event _M_ev; + + // Final status of the send + volatile message_status _M_fStatus; + + // A lock for modifying the buffer or the connected blocks + ::Concurrency::details::_ReentrantPPLLock _M_internalLock; + + // Connected targets + _Target_registry _M_connectedTargets; + + volatile long _M_referenceCount; + }; + + // The Originator messaging block class is internal to the send function. + template <class _Type> + class _AsyncOriginator : public ISource<_Type> + { + public: + + typedef single_link_registry<ITarget<_Type>> _Target_registry; + + // Cleans up any resources that may have been created by the AsyncOriginator. + virtual ~_AsyncOriginator() + { + unlink_targets(); + + delete _M_pMessage; + } + + // Removes a target messaging block for this AsyncOriginator + virtual void unlink_target(ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + bool _Unlinked = false; + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + + if (_M_connectedTargets.remove(_PTarget)) + { + _Invoke_unlink_source(_PTarget); + _Unlinked = true; + } + } + + // Release the lock before decrementing the refcount. Otherwise, the + // lock release could corrupt memory. + if (_Unlinked) + { + _Release_ref(); + } + } + + // Removes the target messaging block from this AsyncOriginator + virtual void unlink_targets() + { + bool _Unlinked = false; + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + + for (_Target_registry::iterator _Iter = _M_connectedTargets.begin(); + *_Iter != NULL; + ++_Iter) + { + ITarget<_Type> * _PTarget = *_Iter; + if (_M_connectedTargets.remove(_PTarget)) + { + _Invoke_unlink_source(_PTarget); + _Unlinked = true; + } + + } + + // All targets should be unlinked + _CONCRT_ASSERT(_M_connectedTargets.count() == 0); + } + + // Release the lock before decrementing the refcount. Otherwise, the + // lock release could corrupt memory. + if (_Unlinked) + { + _Release_ref(); + } + } + + // Accept on this AsyncOriginator is called by a target to take ownership of a + // propagated message. This can only be called from propagate. + virtual message<_Type> * accept(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + return NULL; + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + return NULL; + } + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return NULL; + } + + // + // If the IDs match, actaully transfer ownership of the message. + // + message<_Type> * _Result = _M_pMessage; + _M_pMessage = NULL; + + return _Result; + } + + // Reserve needs to be defined for ISource blocks, but AsyncOriginator doesn't need to + // do anything for reservation because there can only be one target block to read + // the data at a later time. + virtual bool reserve(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + return false; + } + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return false; + } + + return true; + } + + // Consume is called by a target messaging block to take ownership of a + // previously reserved message. + virtual message<_Type> * consume(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + throw bad_target(); + } + + if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId) + { + return NULL; + } + + // The ownership of this message has changed. Set the internal pointer to NULL + // so it won't be deleted in the destructor + + message<_Type> * _Result = _M_pMessage; + _M_pMessage = NULL; + + // We are done. Unlink from the target. DO NOT TOUCH "this" pointer after unlink + unlink_target(_PTarget); + + return _Result; + } + + // Release needs to be defined for ISource blocks, but AsyncOriginator doesn't need to + // do anything for reservation release because there can only be one target block to read + // the data at a later time. + virtual void release(runtime_object_identity _MsgId, ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + if (!_M_connectedTargets.contains(_PTarget)) + { + throw bad_target(); + } + + if ((_M_pMessage == NULL) || (_M_pMessage->msg_id() != _MsgId)) + { + throw message_not_found(); + } + + // We can be connected to only 1 target. Unlink from the target. + // DO NOT TOUCH "this" pointer after unlink + unlink_target(_PTarget); + } + + virtual void acquire_ref(_Inout_ ITarget<_Type> *) + { + _Acquire_ref(); + } + + virtual void release_ref(_Inout_ ITarget<_Type> *) + { + _Release_ref(); + } + + private: + + friend class _Originator; + + // Create an AsyncOriginator (constructor is private to ensure that + // it is allocated on the heap). + _AsyncOriginator() : + _M_pMessage(NULL), + _M_refcount(0) + { + } + + // Send the given value to the target + bool _internal_send(ITarget<_Type> * _PTarget, _Type const & _Value) + { + // Keep a refcount so that this object doesn't get deleted if + // the target decides to unlink before we release our lock + _Acquire_ref(); + + message_status _Status = declined; + message<_Type> * _Msg = new message<_Type>(_Value); + + { + // Hold the lock to ensure that the target doesn't unlink while + // propagation is in progress. + _R_lock _Lock(_M_internalLock); + + // link to the target, create a message and send it + link_target(_PTarget); + + _CONCRT_ASSERT(_M_pMessage == NULL); + _M_pMessage = _Msg; + + _Status = _PTarget->propagate(_M_pMessage, this); + } + + // If the status is anything other than postponed, unlink away + // from the target and delete the AsyncOriginator. + if (_Status != postponed) + { + unlink_target(_PTarget); + } + + // Release the reference acquired above + _Release_ref(); + + return (_Status == accepted); + } + + // Add a target messaging block for this AsyncOriginator + virtual void link_target(ITarget<_Type> * _PTarget) + { + if (_PTarget == NULL) + { + throw std::invalid_argument("_PTarget"); + } + + // Acquire a reference that will be released by unlink_target + _Acquire_ref(); + _M_connectedTargets.add(_PTarget); + _Invoke_link_source(_PTarget); + + // There should be no pending messages to propagate at this time. + _CONCRT_ASSERT(_M_pMessage == NULL); + + } + + // Acquire a reference on the async originator object + void _Acquire_ref() + { + _InterlockedIncrement(&_M_refcount); + } + + // Release the reference on the async originator object. The object + // will be deleted when the reference count goes to 0. + void _Release_ref() + { + _CONCRT_ASSERT(_M_refcount > 0); + if (_InterlockedDecrement(&_M_refcount) == 0) + { + delete this; + } + } + + // The message that will be propagated by the AsyncOriginator + message<_Type> * _M_pMessage; + + // Reference count to manage object lifetime + volatile long _M_refcount; + + // The internal lock for this block for its message + ::Concurrency::details::_ReentrantPPLLock _M_internalLock; + + // connected targets + _Target_registry _M_connectedTargets; + }; + + // static class that exposes methods to initiate messages into + // a dataflow network + class _Originator + { + public: + + // Synchronous initiation of messages + template <class _Type> + static bool _send(ITarget<_Type> * _Trg, const _Type& _Data) + { + if (_Trg != NULL && _Trg->supports_anonymous_source()) + { + // _send will block until the message is accepted/rejected. + // Note that this invokes the send method on the target which + // would synchronously process the message. + _AnonymousOriginator<_Type> _Send_block; + return _Send_block._internal_send(_Trg, _Data); + } + else + { + // Create a blocking originator on the stack. _send will block until the + // message is accepted/rejected. + _SyncOriginator<_Type> _Orig; + return _Orig._internal_send(_Trg, _Data); + } + } + + // Asynchronous initiation of messages + template <class _Type> + static bool _asend(ITarget<_Type> * _Trg, const _Type& _Data) + { + // If the block can participate in posting messages without requiring a call back, use that + // method of initiating the message rather for efficiency purposes. + if (_Trg != NULL && _Trg->supports_anonymous_source()) + { + _AnonymousOriginator<_Type> _Asend_block; + return _Asend_block._internal_asend(_Trg, _Data); + } + else + { + // Needs to be allocated on the heap + _AsyncOriginator<_Type> * _AsyncOrig = new _AsyncOriginator<_Type>; + return _AsyncOrig->_internal_send(_Trg, _Data); + } + } + }; + +} // namespace details + +/// <summary> +/// A synchronous send operation, which waits until the target either accepts or declines the message. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Trg"> +/// A pointer or reference to the target to which data is sent. +/// </param> +/// <param name="_Data"> +/// A reference to the data to be sent. +/// </param> +/// <returns> +/// <c>true</c> if the message was accepted, <c>false</c> otherwise. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool send(_Inout_ ITarget<_Type> * _Trg, const _Type& _Data) +{ + return details::_Originator::_send(_Trg, _Data); +} + + +/// <summary> +/// A synchronous send operation, which waits until the target either accepts or declines the message. +/// </summary> +/// <typeparam name="_Type"> +/// The payload type. +/// </typeparam> +/// <param name="_Trg"> +/// A pointer or reference to the target to which data is sent. +/// </param> +/// <param name="_Data"> +/// A reference to the data to be sent. +/// </param> +/// <returns> +/// <c>true</c> if the message was accepted, <c>false</c> otherwise. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="asend Function"/> +/**/ +template <class _Type> +bool send(ITarget<_Type> &_Trg, const _Type &_Data) +{ + return send(&_Trg, _Data); +} + +/// <summary> +/// An asynchronous send operation, which schedules a task to propagate the data to the target block. +/// </summary> +/// <typeparam name="_Type"> +/// The type of the data to be sent. +/// </typeparam> +/// <param name="_Trg"> +/// A pointer or reference to the target to which data is sent. +/// </param> +/// <param name="_Data"> +/// A reference to the data to be sent. +/// </param> +/// <returns> +/// <c>true</c> if the message was accepted before the method returned, <c>false</c> otherwise. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/**/ +template <class _Type> +bool asend(_Inout_ ITarget<_Type> * _Trg, const _Type& _Data) +{ + return details::_Originator::_asend(_Trg, _Data); +} + + +/// <summary> +/// An asynchronous send operation, which schedules a task to propagate the value to the target block. +/// </summary> +/// <typeparam name="_Type"> +/// The type of the data to be sent. +/// </typeparam> +/// <param name="_Trg"> +/// A pointer or reference to the target to which data is sent. +/// </param> +/// <param name="_Data"> +/// A reference to the data to be sent. +/// </param> +/// <returns> +/// <c>true</c> if the message was accepted, <c>false</c> otherwise. +/// </returns> +/// <remarks> +/// For more information, see <see cref="Message Passing Functions"/>. +/// </remarks> +/// <seealso cref="receive Function"/> +/// <seealso cref="try_receive Function"/> +/// <seealso cref="send Function"/> +/**/ +template <class _Type> +bool asend(ITarget<_Type> &_Trg, const _Type &_Data) +{ + return asend(&_Trg, _Data); +} + +/// <summary> +/// Associates the given name to the message block or agent in the ETW trace. +/// </summary> +/// <typeparam name="_Type"> +/// The type of the object. This is typically a message block or an agent. +/// </typeparam> +/// <param name="_PObject"> +/// A pointer to the message block or agent that is being named in the trace. +/// </param> +/// <param name="_Name"> +/// The name for the given object. +/// </param> +template <class _Type> +void Trace_agents_register_name(_Inout_ _Type * _PObject, _In_z_ const wchar_t * _Name) +{ + _Trace_agents(AGENTS_EVENT_NAME, ::Concurrency::details::_Trace_agents_get_id(_PObject), _Name); +} + +} // namespace Concurrency + +namespace concurrency = Concurrency; + +#pragma warning(pop) +#pragma pack(pop) diff --git a/test_data/lots_of_files/align.c b/test_data/lots_of_files/align.c new file mode 100644 index 0000000..5fbbf65 --- /dev/null +++ b/test_data/lots_of_files/align.c @@ -0,0 +1,474 @@ +/*** +*align.c - Aligned allocation, reallocation or freeing of memory in the heap +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines the _aligned_malloc(), +* _aligned_realloc(), +* _aligned_recalloc(), +* _aligned_offset_malloc(), +* _aligned_offset_realloc(), +* _aligned_offset_recalloc(), +* _aligned_free(), +* _aligned_msize() functions. +* +*******************************************************************************/ + +#include <dbgint.h> +#include <crtdbg.h> +#include <errno.h> +#include <string.h> +#include <malloc.h> +#include <stddef.h> +#include <stdlib.h> +#include <internal.h> + +#define IS_2_POW_N(X) (((X)&(X-1)) == 0) +#define PTR_SZ sizeof(void *) +/*** +* +* |1|___6___|2|3|4|_________5__________|_6_| +* +* 1 -> Pointer to start of the block allocated by malloc. +* 2 -> Value of 1. +* 3 -> Gap used to get 1 aligned on sizeof(void *). +* 4 -> Pointer to the start of data block. +* 4+5 -> Data block. +* 6 -> Wasted memory at rear of data block. +* 6 -> Wasted memory. +* +*******************************************************************************/ + +/*** +* void *_aligned_malloc_base(size_t size, size_t alignment) +* - Get a block of aligned memory from the heap. +* +* Purpose: +* Allocate of block of aligned memory aligned on the alignment of at least +* size bytes from the heap and return a pointer to it. +* +* Entry: +* size_t size - size of block requested +* size_t alignment - alignment of memory (needs to be a power of 2) +* +* Exit: +* Success: Pointer to memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +void * __cdecl _aligned_malloc_base( + size_t size, + size_t alignment + ) +{ + return _aligned_offset_malloc_base(size, alignment, 0); +} +/*** +* void *_aligned_offset_malloc_base(size_t size, size_t alignment, int offset) +* - Get a block of memory from the heap. +* +* Purpose: +* Allocate a block of memory which is shifted by offset from alignment of +* at least size bytes from the heap and return a pointer to it. +* +* Entry: +* size_t size - size of block of memory +* size_t alignment - alignment of memory (needs to be a power of 2) +* size_t offset - offset of memory from the alignment +* +* Exit: +* Success: Pointer to memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + + +void * __cdecl _aligned_offset_malloc_base( + size_t size, + size_t align, + size_t offset + ) +{ + uintptr_t ptr, retptr, gap; + size_t nonuser_size,block_size; + + /* validation section */ + _VALIDATE_RETURN(IS_2_POW_N(align), EINVAL, NULL); + _VALIDATE_RETURN(offset == 0 || offset < size, EINVAL, NULL); + + align = (align > PTR_SZ ? align : PTR_SZ) -1; + + /* gap = number of bytes needed to round up offset to align with PTR_SZ*/ + gap = (0 - offset)&(PTR_SZ -1); + + nonuser_size = PTR_SZ +gap +align; + block_size = nonuser_size + size; + _VALIDATE_RETURN_NOEXC(size <= block_size, ENOMEM, NULL) + + if ( (ptr =(uintptr_t)malloc(block_size)) == (uintptr_t)NULL) + return NULL; + + retptr =((ptr +nonuser_size+offset)&~align)- offset; + ((uintptr_t *)(retptr - gap))[-1] = ptr; + + return (void *)retptr; +} + +/*** +* +* void *_aligned_realloc_base(void * memblock, size_t size, size_t alignment) +* - Reallocate a block of aligned memory from the heap. +* +* Purpose: +* Reallocates of block of aligned memory aligned on the alignment of at +* least size bytes from the heap and return a pointer to it. Size can be +* either greater or less than the original size of the block. +* The reallocation may result in moving the block as well as changing the +* size. +* +* Entry: +* void *memblock - pointer to block in the heap previously allocated by +* call to _aligned_malloc(), _aligned_offset_malloc(), +* _aligned_realloc() or _aligned_offset_realloc(). +* size_t size - size of block requested +* size_t alignment - alignment of memory +* +* Exit: +* Success: Pointer to re-allocated memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +void * __cdecl _aligned_realloc_base( + void *memblock, + size_t size, + size_t alignment + ) +{ + return _aligned_offset_realloc_base(memblock, size, alignment, 0); +} + +/*** +* +* void *_aligned_recalloc_base(void * memblock, size_t count, size_t size, size_t alignment) +* - Reallocate a block of aligned memory from the heap. +* +* Purpose: +* Reallocates of block of aligned memory aligned on the alignment of at +* least size bytes from the heap and return a pointer to it. Size can be +* either greater or less than the original size of the block. +* The reallocation may result in moving the block as well as changing the +* size. +* +* Entry: +* void *memblock - pointer to block in the heap previously allocated by +* call to _aligned_malloc(), _aligned_offset_malloc(), +* _aligned_realloc() or _aligned_offset_realloc(). +* size_t count - count of items +* size_t size - size of item +* size_t alignment - alignment of memory +* +* Exit: +* Success: Pointer to re-allocated memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +void * __cdecl _aligned_recalloc_base( + void *memblock, + size_t count, + size_t size, + size_t alignment + ) +{ + return _aligned_offset_recalloc_base(memblock, count, size, alignment, 0); +} + +/*** +* +* void *_aligned_offset_realloc_base (void * memblock, size_t size, +* size_t alignment, int offset) +* - Reallocate a block of memory from the heap. +* +* Purpose: +* Reallocates a block of memory which is shifted by offset from +* alignment of at least size bytes from the heap and return a pointer +* to it. Size can be either greater or less than the original size of the +* block. +* +* Entry: +* void *memblock - pointer to block in the heap previously allocated by +* call to _aligned_malloc(), _aligned_offset_malloc(), +* _aligned_realloc() or _aligned_offset_realloc(). +* size_t size - size of block of memory +* size_t alignment - alignment of memory +* size_t offset - offset of memory from the alignment +* +* Exit: +* Success: Pointer to re-allocated memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +void * __cdecl _aligned_offset_realloc_base( + void *memblock, + size_t size, + size_t align, + size_t offset + ) +{ + uintptr_t ptr, retptr, gap, stptr, diff; + uintptr_t movsz, reqsz; + int bFree = 0; + + /* special cases */ + if (memblock == NULL) + { + return _aligned_offset_malloc_base(size, align, offset); + } + if (size == 0) + { + _aligned_free_base(memblock); + return NULL; + } + + /* validation section */ + _VALIDATE_RETURN(IS_2_POW_N(align), EINVAL, NULL); + _VALIDATE_RETURN(offset == 0 || offset < size, EINVAL, NULL); + + stptr = (uintptr_t)memblock; + + /* ptr points to the pointer to starting of the memory block */ + stptr = (stptr & ~(PTR_SZ -1)) - PTR_SZ; + + /* ptr is the pointer to the start of memory block*/ + stptr = *((uintptr_t *)stptr); + + align = (align > PTR_SZ ? align : PTR_SZ) -1; + /* gap = number of bytes needed to round up offset to align with PTR_SZ*/ + gap = (0 -offset)&(PTR_SZ -1); + + diff = (uintptr_t)memblock - stptr; + /* Mov size is min of the size of data available and sizw requested. + */ + CRT_WARNING_DISABLE_PUSH(22018, "Silence prefast about overflow/underflow"); + movsz = _msize((void *)stptr) - ((uintptr_t)memblock - stptr); + CRT_WARNING_POP + movsz = movsz > size? size: movsz; + reqsz = PTR_SZ +gap +align +size; + + _VALIDATE_RETURN_NOEXC(size <= reqsz, ENOMEM, NULL); + + /* First check if we can expand(reducing or expanding using expand) data + * safely, ie no data is lost. eg, reducing alignment and keeping size + * same might result in loss of data at the tail of data block while + * expanding. + * + * If no, use malloc to allocate the new data and move data. + * + * If yes, expand and then check if we need to move the data. + */ + if ((stptr +align +PTR_SZ +gap)<(uintptr_t)memblock) + { + if ((ptr = (uintptr_t)malloc(reqsz)) == (uintptr_t) NULL) + return NULL; + bFree = 1; + } + else + { + /* we need to save errno, which can be modified by _expand */ + errno_t save_errno = errno; + if ((ptr = (uintptr_t)_expand((void *)stptr, reqsz)) == (uintptr_t)NULL) + { + errno = save_errno; + if ((ptr = (uintptr_t)malloc(reqsz)) == (uintptr_t) NULL) + return NULL; + bFree = 1; + } + else + stptr = ptr; + } + + + if ( ptr == ((uintptr_t)memblock - diff) + && !( ((size_t)memblock + gap +offset) & ~(align) )) + { + return memblock; + } + + retptr =((ptr +PTR_SZ +gap +align +offset)&~align)- offset; + memmove((void *)retptr, (void *)(stptr + diff), movsz); + if ( bFree) + free ((void *)stptr); + + ((uintptr_t *)(retptr - gap))[-1] = ptr; + return (void *)retptr; +} + + +/*** +* +* size_t _aligned_msize_base(void *memblock, size_t align, size_t offset) +* +* Purpose: +* Computes the size of an aligned block. +* +* Entry: +* void * memblock - pointer to the aligned block of memory +* +* Exceptions: +* None. If memblock == NULL 0 is returned. +* +*******************************************************************************/ + +size_t __cdecl _aligned_msize_base(void *memblock, size_t align, size_t offset) +{ + size_t header_size = 0; /* Size of the header block */ + size_t footer_size = 0; /* Size of the footer block */ + size_t total_size = 0; /* total size of the allocated block */ + size_t user_size = 0; /* size of the user block*/ + uintptr_t gap = 0; /* keep the alignment of the data block */ + /* after the sizeof(void*) aligned pointer */ + /* to the beginning of the allocated block */ + uintptr_t ptr = 0; /* computes the beginning of the allocated block */ + + _VALIDATE_RETURN (memblock != NULL, EINVAL, -1); + + /* HEADER SIZE + FOOTER SIZE = GAP + ALIGN + SIZE OF A POINTER*/ + /* HEADER SIZE + USER SIZE + FOOTER SIZE = TOTAL SIZE */ + + ptr = (uintptr_t)memblock; /* ptr points to the start of the aligned memory block */ + ptr = (ptr & ~(PTR_SZ - 1)) - PTR_SZ; /* ptr is one position behind memblock */ + /* the value in ptr is the start of the real allocated block */ + ptr = *((uintptr_t *)ptr); /* after dereference ptr points to the beginning of the allocated block */ + + total_size = _msize((void*)ptr); + header_size = (uintptr_t) memblock - ptr; + gap = (0 - offset) & (PTR_SZ - 1); + /* Alignment cannot be less than sizeof(void*) */ + align = (align > PTR_SZ ? align : PTR_SZ) -1; + footer_size = gap + align + PTR_SZ - header_size; + user_size = total_size - header_size - footer_size; + + return user_size; +} + +/*** +* +* void *_aligned_offset_recalloc_base (void * memblock, size_t size, size_t count, size_t alignment, int offset) +* - Reallocate a block of memory from the heap. +* +* Purpose: +* Reallocates a block of memory which is shifted by offset from +* alignment of at least size bytes from the heap and return a pointer +* to it. Size can be either greater or less than the original size of the +* block. +* +* Entry: +* void *memblock - pointer to block in the heap previously allocated by +* call to _aligned_malloc(), _aligned_offset_malloc(), +* _aligned_realloc() or _aligned_offset_realloc(). +* size_t count - count of items +* size_t size - size of items +* size_t alignment - alignment of memory +* size_t offset - offset of memory from the alignment +* +* Exit: +* Success: Pointer to re-allocated memory block +* Failure: Null, errno is set +* +* Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* +*******************************************************************************/ + +void * __cdecl _aligned_offset_recalloc_base( + void * memblock, + size_t count, + size_t size, + size_t align, + size_t offset + ) +{ + size_t user_size = 0; /* wanted size, passed to aligned realoc */ + size_t start_fill = 0; /* location where aligned recalloc starts to fill with 0 */ + /* filling must start from the end of the previous user block */ + void * retptr = NULL; /* result of aligned recalloc*/ + uintptr_t ptr = 0; /* points to the beginning of the allocated block*/ + + /* ensure that (size * num) does not overflow */ + if (count > 0) + { + _VALIDATE_RETURN_NOEXC((_HEAP_MAXREQ / count) >= size, ENOMEM, NULL); + } + + user_size = size * count; + + if (memblock != NULL) + { + start_fill = _aligned_msize(memblock, align, offset); + } + + retptr = _aligned_offset_realloc_base(memblock, user_size, align, offset); + + if (retptr != NULL) + { + if (start_fill < user_size) + { + memset ((char*)retptr + start_fill, 0, user_size - start_fill); + } + } + return retptr; +} + +/*** +* +* void *_aligned_free_base(void *memblock) +* - Free the memory which was allocated using _aligned_malloc or +* _aligned_offset_memory +* +* Purpose: +* Frees the aligned memory block which was allocated using _aligned_malloc. +* +* Entry: +* void * memblock - pointer to the block of memory +* +* Exceptions: +* None. If memblock == NULL we simply return without doing anything. +* +*******************************************************************************/ + +void __cdecl _aligned_free_base(void *memblock) +{ + uintptr_t ptr; + + if (memblock == NULL) + return; + + ptr = (uintptr_t)memblock; + + /* ptr points to the pointer to starting of the memory block */ + ptr = (ptr & ~(PTR_SZ -1)) - PTR_SZ; + + /* ptr is the pointer to the start of memory block*/ + ptr = *((uintptr_t *)ptr); + free((void *)ptr); +} + diff --git a/test_data/lots_of_files/align.h b/test_data/lots_of_files/align.h new file mode 100644 index 0000000..29020d4 --- /dev/null +++ b/test_data/lots_of_files/align.h @@ -0,0 +1,30 @@ +// ==++== +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ==--== +// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +// +// align.h +// +// Alignment / Packing definitions +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +#define WORD_ALIGN 1 +#define DWORD_ALIGN 3 +#define QWORD_ALIGN 7 +#define DQWORD_ALIGN 15 + +#ifdef _WIN64 +#define P2_ALIGN 15 +#else // !_WIN64 +#define P2_ALIGN 7 +#endif // _WIN64 + +#define ALIGNED_SIZE(size, alignment) (((size) + (alignment)) & ~(alignment)) + +#ifndef SIZEOF_ARRAY +#define SIZEOF_ARRAY(x) ((sizeof(x))/(sizeof(x[0]))) +#endif // SIZEOF_ARRAY + diff --git a/test_data/lots_of_files/ammintrin.h b/test_data/lots_of_files/ammintrin.h new file mode 100644 index 0000000..0877e48 --- /dev/null +++ b/test_data/lots_of_files/ammintrin.h @@ -0,0 +1,298 @@ +/**** +* Copyright (C) 2007-2008 Advanced Micro Devices Inc. All rights reserved. +* +* The information and source code contained herein is the exclusive +* property of Advanced Micro Devices and may not be disclosed, examined +* or reproduced in whole or in part without explicit written authorization +* from the company. +* +* ammintrin.h - Definitions for AMD-specific intrinsics +* +****/ + +#pragma once +#ifndef __midl +#ifndef _INCLUDED_AMM +#define _INCLUDED_AMM + +#if defined (_M_CEE_PURE) + #error ERROR: This file is not supported in the pure mode! +#else /* defined (_M_CEE_PURE) */ + +#if defined __cplusplus +extern "C" { /* Intrinsics use C name-mangling. */ +#endif /* defined __cplusplus */ + +/* + * Vector integer comparison control macros + */ + +#define _MM_PCOMCTRL_LT 0 +#define _MM_PCOMCTRL_LE 1 +#define _MM_PCOMCTRL_GT 2 +#define _MM_PCOMCTRL_GE 3 +#define _MM_PCOMCTRL_EQ 4 +#define _MM_PCOMCTRL_NEQ 5 +#define _MM_PCOMCTRL_FALSE 6 +#define _MM_PCOMCTRL_TRUE 7 + +/* + * MACRO functions for vector integer comparisons + */ + +#define _mm_comlt_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epu8(v1, v2) _mm_com_epu8(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epu16(v1, v2) _mm_com_epu16(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epu32(v1, v2) _mm_com_epu32(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epu64(v1, v2) _mm_com_epu64(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epi8(v1, v2) _mm_com_epi8(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epi16(v1, v2) _mm_com_epi16(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epi32(v1, v2) _mm_com_epi32(v1, v2, _MM_PCOMCTRL_TRUE) + +#define _mm_comlt_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_LT) +#define _mm_comle_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_LE) +#define _mm_comgt_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_GT) +#define _mm_comge_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_GE) +#define _mm_comeq_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_EQ) +#define _mm_comneq_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_NEQ) +#define _mm_comfalse_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_FALSE) +#define _mm_comtrue_epi64(v1, v2) _mm_com_epi64(v1, v2, _MM_PCOMCTRL_TRUE) + +/* SSE5 intrinsics */ + +/* Float/double multiply-accumulate */ +__m128 _mm_macc_ps(__m128, __m128, __m128); +__m128d _mm_macc_pd(__m128d, __m128d, __m128d); +__m128 _mm_macc_ss(__m128, __m128, __m128); +__m128d _mm_macc_sd(__m128d, __m128d, __m128d); +__m128 _mm_maddsub_ps(__m128, __m128, __m128); +__m128d _mm_maddsub_pd(__m128d, __m128d, __m128d); +__m128 _mm_msubadd_ps(__m128, __m128, __m128); +__m128d _mm_msubadd_pd(__m128d, __m128d, __m128d); +__m128 _mm_msub_ps(__m128, __m128, __m128); +__m128d _mm_msub_pd(__m128d, __m128d, __m128d); +__m128 _mm_msub_ss(__m128, __m128, __m128); +__m128d _mm_msub_sd(__m128d, __m128d, __m128d); +__m128 _mm_nmacc_ps(__m128, __m128, __m128); +__m128d _mm_nmacc_pd(__m128d, __m128d, __m128d); +__m128 _mm_nmacc_ss(__m128, __m128, __m128); +__m128d _mm_nmacc_sd(__m128d, __m128d, __m128d); +__m128 _mm_nmsub_ps(__m128, __m128, __m128); +__m128d _mm_nmsub_pd(__m128d, __m128d, __m128d); +__m128 _mm_nmsub_ss(__m128, __m128, __m128); +__m128d _mm_nmsub_sd(__m128d, __m128d, __m128d); + +/* Integer multiply-accumulate */ +__m128i _mm_maccs_epi16(__m128i, __m128i, __m128i); +__m128i _mm_macc_epi16(__m128i, __m128i, __m128i); +__m128i _mm_maccsd_epi16(__m128i, __m128i, __m128i); +__m128i _mm_maccd_epi16(__m128i, __m128i, __m128i); +__m128i _mm_maccs_epi32(__m128i, __m128i, __m128i); +__m128i _mm_macc_epi32(__m128i, __m128i, __m128i); +__m128i _mm_maccslo_epi32(__m128i, __m128i, __m128i); +__m128i _mm_macclo_epi32(__m128i, __m128i, __m128i); +__m128i _mm_maccshi_epi32(__m128i, __m128i, __m128i); +__m128i _mm_macchi_epi32(__m128i, __m128i, __m128i); +__m128i _mm_maddsd_epi16(__m128i, __m128i, __m128i); +__m128i _mm_maddd_epi16(__m128i, __m128i, __m128i); + +/* Horizontal add/subtract */ +__m128i _mm_haddw_epi8(__m128i); +__m128i _mm_haddd_epi8(__m128i); +__m128i _mm_haddq_epi8(__m128i); +__m128i _mm_haddd_epi16(__m128i); +__m128i _mm_haddq_epi16(__m128i); +__m128i _mm_haddq_epi32(__m128i); +__m128i _mm_haddw_epu8(__m128i); +__m128i _mm_haddd_epu8(__m128i); +__m128i _mm_haddq_epu8(__m128i); +__m128i _mm_haddd_epu16(__m128i); +__m128i _mm_haddq_epu16(__m128i); +__m128i _mm_haddq_epu32(__m128i); +__m128i _mm_hsubw_epi8(__m128i); +__m128i _mm_hsubd_epi16(__m128i); +__m128i _mm_hsubq_epi32(__m128i); + +/* Vector conditional moves */ +__m128i _mm_cmov_si128(__m128i, __m128i, __m128i); +__m128i _mm_perm_epi8(__m128i, __m128i, __m128i); + +/* Vector shifts and rotates */ +__m128i _mm_rot_epi8(__m128i, __m128i); +__m128i _mm_rot_epi16(__m128i, __m128i); +__m128i _mm_rot_epi32(__m128i, __m128i); +__m128i _mm_rot_epi64(__m128i, __m128i); +__m128i _mm_roti_epi8(__m128i, int); +__m128i _mm_roti_epi16(__m128i, int); +__m128i _mm_roti_epi32(__m128i, int); +__m128i _mm_roti_epi64(__m128i, int); +__m128i _mm_shl_epi8(__m128i, __m128i); +__m128i _mm_shl_epi16(__m128i, __m128i); +__m128i _mm_shl_epi32(__m128i, __m128i); +__m128i _mm_shl_epi64(__m128i, __m128i); +__m128i _mm_sha_epi8(__m128i, __m128i); +__m128i _mm_sha_epi16(__m128i, __m128i); +__m128i _mm_sha_epi32(__m128i, __m128i); +__m128i _mm_sha_epi64(__m128i, __m128i); + +/* Vector integer comparisons */ + +__m128i _mm_com_epu8(__m128i, __m128i, int); +__m128i _mm_com_epu16(__m128i, __m128i, int); +__m128i _mm_com_epu32(__m128i, __m128i, int); +__m128i _mm_com_epu64(__m128i, __m128i, int); +__m128i _mm_com_epi8(__m128i, __m128i, int); +__m128i _mm_com_epi16(__m128i, __m128i, int); +__m128i _mm_com_epi32(__m128i, __m128i, int); +__m128i _mm_com_epi64(__m128i, __m128i, int); + +/* Precision control */ + +__m128 _mm_frcz_ps(__m128); +__m128d _mm_frcz_pd(__m128d); +__m128 _mm_frcz_ss(__m128, __m128); +__m128d _mm_frcz_sd(__m128d, __m128d); + +/* Control values for permute2 intrinsics */ +#define _MM_PERMUTE2_COPY 0 /* just copy the selected value */ +/* Note that using the constant 1 would have the same effect as 0 */ +#define _MM_PERMUTE2_ZEROIF1 2 /* zero selected value if src3 bit is 1 */ +#define _MM_PERMUTE2_ZEROIF0 3 /* zero selected value if src3 bit is 3 */ + +/* Permutation */ +__m128 _mm_permute2_ps(__m128, __m128, __m128i, int); +__m128d _mm_permute2_pd(__m128d, __m128d, __m128i, int); + + +/* YMM versions */ +__m256 _mm256_macc_ps(__m256, __m256, __m256); +__m256d _mm256_macc_pd(__m256d, __m256d, __m256d); +__m256 _mm256_maddsub_ps(__m256, __m256, __m256); +__m256d _mm256_maddsub_pd(__m256d, __m256d, __m256d); +__m256 _mm256_msubadd_ps(__m256, __m256, __m256); +__m256d _mm256_msubadd_pd(__m256d, __m256d, __m256d); +__m256 _mm256_msub_ps(__m256, __m256, __m256); +__m256d _mm256_msub_pd(__m256d, __m256d, __m256d); +__m256 _mm256_nmacc_ps(__m256, __m256, __m256); +__m256d _mm256_nmacc_pd(__m256d, __m256d, __m256d); +__m256 _mm256_nmsub_ps(__m256, __m256, __m256); +__m256d _mm256_nmsub_pd(__m256d, __m256d, __m256d); +__m256i _mm256_cmov_si256(__m256i, __m256i, __m256i); +__m256 _mm256_frcz_ps(__m256); +__m256d _mm256_frcz_pd(__m256d); +__m256 _mm256_permute2_ps(__m256, __m256, __m256i, int); +__m256d _mm256_permute2_pd(__m256d, __m256d, __m256i, int); + +/* LWP intrinsics */ +void __llwpcb(void *); +void *__slwpcb(); +void __lwpval32(unsigned int, unsigned int, unsigned int); +unsigned char __lwpins32(unsigned int, unsigned int, unsigned int); +#if defined (_M_X64) +void __lwpval64(unsigned __int64, unsigned int, unsigned int); +unsigned char __lwpins64(unsigned __int64, unsigned int, unsigned int); +#endif /* defined (_M_X64) */ + +/*BMI intrinsics */ +unsigned int _bextr_u32(unsigned int, unsigned int, unsigned int); +unsigned int _andn_u32(unsigned int, unsigned int); +unsigned int _tzcnt_u32(unsigned int); +unsigned int _lzcnt_u32(unsigned int); +unsigned int _blsr_u32(unsigned int); +unsigned int _blsmsk_u32(unsigned int); +unsigned int _blsi_u32(unsigned int); +#if defined (_M_X64) +unsigned __int64 _bextr_u64(unsigned __int64, unsigned int, unsigned int); +unsigned __int64 _andn_u64(unsigned __int64, unsigned __int64); +unsigned __int64 _tzcnt_u64(unsigned __int64); +unsigned __int64 _lzcnt_u64(unsigned __int64); +unsigned __int64 _blsr_u64(unsigned __int64); +unsigned __int64 _blsmsk_u64(unsigned __int64); +unsigned __int64 _blsi_u64(unsigned __int64); +#endif /* defined (_M_X64) */ + +/* TBM intrinsics */ +unsigned int _bextri_u32(unsigned int, unsigned int); +unsigned int _blcfill_u32(unsigned int); +unsigned int _blsfill_u32(unsigned int); +unsigned int _blcs_u32(unsigned int); +unsigned int _tzmsk_u32(unsigned int); +unsigned int _blcic_u32(unsigned int); +unsigned int _blsic_u32(unsigned int); +unsigned int _t1mskc_u32(unsigned int); +unsigned int _blcmsk_u32(unsigned int); +unsigned int _blci_u32(unsigned int); +#if defined (_M_X64) +unsigned __int64 _bextri_u64(unsigned __int64, unsigned int); +unsigned __int64 _blcfill_u64(unsigned __int64); +unsigned __int64 _blsfill_u64(unsigned __int64); +unsigned __int64 _blcs_u64(unsigned __int64); +unsigned __int64 _tzmsk_u64(unsigned __int64); +unsigned __int64 _blcic_u64(unsigned __int64); +unsigned __int64 _blsic_u64(unsigned __int64); +unsigned __int64 _t1mskc_u64(unsigned __int64); +unsigned __int64 _blcmsk_u64(unsigned __int64); +unsigned __int64 _blci_u64(unsigned __int64); +#endif /* defined (_M_X64) */ + +#if defined __cplusplus +}; /* End "C" */ +#endif /* defined __cplusplus */ + +#endif /* defined (_M_CEE_PURE) */ +#endif /* _INCLUDED_AMM */ +#endif /* __midl */ diff --git a/test_data/lots_of_files/amp.h b/test_data/lots_of_files/amp.h new file mode 100644 index 0000000..18b603c --- /dev/null +++ b/test_data/lots_of_files/amp.h @@ -0,0 +1,7554 @@ +/*** +* ==++== +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* ==--== +* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +* +* amp.h +* +* C++ AMP Library +* +* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +****/ + +#pragma once + +#include <crtdbg.h> +#include <vector> +#include <iterator> +#include <future> + +#include <amprt.h> +#include <xxamp.h> +#include <type_traits> + +#define _AMP_H + +#pragma pack(push,8) + + +namespace Concurrency +{ + +/// <summary> +/// Define an N-dimensional index point; which may also be viewed as a vector +/// based at the origin in N-space. +/// +/// The index<N> type represents an N-dimensional vector of int which specifies +/// a unique position in an N-dimensional space. The values in the coordinate +/// vector are ordered from most-significant to least-significant. Thus, in +/// 2-dimensional space, the index vector (5,3) represents the position at +/// row 5, column 3. +/// +/// The position is relative to the origin in the N-dimensional space, and can +/// contain negative component values. +/// </summary> +/// +/// <param name="_Rank"> +/// The dimensionality space into which this index applies, can be any integer +/// greater than 0. +/// </param> +template <int _Rank> class index +{ +public: + _CPP_AMP_VERIFY_RANK(_Rank, index); + + template <typename _Value_type, int _Rank> + friend class array; + + template <int _Rank, int _Element_size> + friend class details::_Array_view_shape; + + template <int _Rank, int _Element_size> + friend class details::_Array_view_base; + + static const int rank = _Rank; + typedef int value_type; + + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + index() __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAssign>::func(*this, 0); + } + + /// <summary> + /// Copy Constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from + /// </param> + index(const index<_Rank>& _Other) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAssign>::func(*this, _Other); + } + + /// <summary> + /// Constructor for index<1> + /// </summary> + /// <param name="_I"> + /// The value for initialization + /// </param> + explicit index(int _I) __GPU + { + static_assert(_Rank == 1, "This constructor can only be used to construct an index<1> object."); + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAssign>::func(*this, _I); + } + + /// <summary> + /// Constructor for index<2> + /// </summary> + /// <param name="_I0"> + /// The index value for dimension 0 + /// </param> + /// <param name="_I1"> + /// The index value for dimension 1 + /// </param> + index(int _I0, int _I1) __GPU + { + static_assert(_Rank == 2, "This constructor can only be used to construct an index<2> object."); + _M_base[0] = _I0; + _M_base[1] = _I1; + } + + /// <summary> + /// Constructor for index<3> + /// </summary> + /// <param name="_I0"> + /// The index value for dimension 0 + /// </param> + /// <param name="_I1"> + /// The index value for dimension 1 + /// </param> + /// <param name="_I2"> + /// The index value for dimension 2 + /// </param> + index(int _I0, int _I1, int _I2) __GPU + { + static_assert(_Rank == 3, "This constructor can only be used to construct an index<3> object."); + _M_base[0] = _I0; + _M_base[1] = _I1; + _M_base[2] = _I2; + } + + /// <summary> + /// Constructs an index<N> with the coordinate values provided the array + /// of int component values. If the coordinate array length is not N, + /// the behavior is undefined. + /// </summary> + /// <param name="_Array"> + /// A single-dimensional array with _Rank elements. + /// </param> + explicit index(const int _Array[_Rank]) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAssign>::func(*this, _Array); + } + + /// <summary> + /// copy-assignment operators + /// </summary> + index<_Rank>& operator=(const index<_Rank>& _Other) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAssign>::func(*this, _Other); + return *this; + } + + /// <summary> + /// Index operator. + /// </summary> + /// <param name="_Index"> + /// An integral value between 0 and _Rank-1. + /// </param> + /// <returns> + /// The corresponding value stored at _Index. + /// </returns> + int operator[] (unsigned _Index) const __GPU + { + return _M_base[_Index]; + } + + /// <summary> + /// Index operator. + /// </summary> + /// <param name="_Index"> + /// An integral value between 0 and _Rank-1. + /// </param> + /// <returns> + /// A reference to the corresponding value stored at _Index. + /// </returns> + int& operator[] (unsigned _Index) __GPU + { + return _M_base[_Index]; + } + + // Operations + + /// <summary> + /// Element-wise addition of this index with another index. + /// </summary> + /// <param name="_Rhs"> + /// The index to add + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator+=(const index<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAddEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Element-wise subtraction of this index with another index. + /// </summary> + /// <param name="_Rhs"> + /// The index to subtract + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator-=(const index<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opSubEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Adds an integer value to each element of this index. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to add + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator+=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAddEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Subtracts an integer value from each element of this index. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to subtract. + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator-=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opSubEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Multiplies each element of this index with an integer value. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to multiply. + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator*=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opMulEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Divides each element of this index by an integer value. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to divide by. + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator/=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opDivEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Modulus an integer value into each element of this index. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to modulus. + /// </param> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator%=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opModEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Pre-increments each element of this index. + /// </summary> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator++() __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAddEq>::func(*this, 1); + return *this; + } + + /// <summary> + /// Post-increments each element of this index. + /// </summary> + /// <returns> + /// The value of the unincremented index. + /// </returns> + index<_Rank> operator++(int) __GPU + { + index<_Rank> old_Index(*this); + details::_compound_assign_op_loop_helper<index<_Rank>, details::opAddEq>::func(*this, 1); + return old_Index; + } + + /// <summary> + /// Pre-decrements each element of this index. + /// </summary> + /// <returns> + /// A reference to this index. + /// </returns> + index<_Rank>& operator--() __GPU + { + details::_compound_assign_op_loop_helper<index<_Rank>, details::opSubEq>::func(*this, 1); + return *this; + } + + /// <summary> + /// Post-decrements each element of this index. + /// </summary> + /// <returns> + /// The value of the undecremented index. + /// </returns> + index operator--(int) __GPU + { + index<_Rank> old_Index(*this); + details::_compound_assign_op_loop_helper<index<_Rank>, details::opSubEq>::func(*this, 1); + return old_Index; + } + +private: + template<class _Tuple_type> + friend + _Tuple_type details::_Create_uninitialized_tuple() __GPU; + + /// <summary> + /// Constructor. + /// </summary> + /// <param name=""> + /// Indicates that no initialization is necessary. + /// </param> + index(details::_eInitializeState) __GPU {} + // + // implementation details - end + + int _M_base[_Rank]; +}; + + +/// <summary> +/// The extent<N> type represents an N-dimensional vector of int which specifies +/// the bounds of an N-dimensional space with an origin of 0. The values in the +/// coordinate vector are ordered from most-significant to least-significant. +/// Thus, in 2-dimensional space, the extent vector (5,3) represents a space +/// with 5 rows and 3 columns. +/// +/// All components of an extent must be non-negative. +/// E.g. +/// extent<3> domain(2, 3, 4); +/// represents all points +/// index<3> _Index; +/// such that +/// 0 <= _Index[0] < 2; +/// 0 <= _Index[1] < 3; +/// 0 <= _Index[2] < 4; +/// </summary> +/// <param name="_Rank"> +/// The _Rank or the dimensionality of the index space. +/// </param> +template <int _Rank> class extent +{ +public: + _CPP_AMP_VERIFY_RANK(_Rank, extent); + + template <typename _Value_type, int _Rank> + friend class array; + + template <int _Rank, int _Element_size> + friend class details::_Array_view_shape; + + template <int _Rank, int _Element_size> + friend class details::_Array_view_base; + + static const int rank = _Rank; + typedef int value_type; + + + /// <summary> + /// Default constructor. The value at each dimension is initialized to zero. + /// </summary> + extent() __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAssign>::func(*this, 0); + } + + /// <summary> + /// Copy constructor. Constructs a new extent from the supplied argument _Other. + /// </summary> + /// <param name="_Other"> + /// The extent instance to be copied from . + /// </param> + extent(const extent<_Rank>& _Other) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAssign>::func(*this, _Other); + } + + /// <summary> + /// Constructor for extent<1>. + /// </summary> + /// <param name="_I"> + /// The value for initialization + /// </param> + explicit extent(int _I) __GPU + { + static_assert(_Rank == 1, "This constructor can only be used to construct an extent<1> object."); + _M_base[0] = _I; + } + + /// <summary> + /// Constructor for extent<2> + /// </summary> + /// <param name="_I0"> + /// The extent value for dimension 0 + /// </param> + /// <param name="_I1"> + /// The extent value for dimension 1 + /// </param> + extent(int _I0, int _I1) __GPU + { + static_assert(_Rank == 2, "This constructor can only be used to construct an extent<2> object."); + _M_base[0] = _I0; + _M_base[1] = _I1; + } + + /// <summary> + /// Constructor for extent<3> + /// </summary> + /// <param name="_I0"> + /// The extent value for dimension 0 + /// </param> + /// <param name="_I1"> + /// The extent value for dimension 1 + /// </param> + /// <param name="_I2"> + /// The extent value for dimension 2 + /// </param> + extent(int _I0, int _I1, int _I2) __GPU + { + static_assert(_Rank == 3, "This constructor can only be used to construct an extent<3> object."); + _M_base[0] = _I0; + _M_base[1] = _I1; + _M_base[2] = _I2; + } + + /// <summary> + /// Constructs an extent with the coordinate values provided the array + /// of int component values. If the coordinate array length is not N, + /// the behavior is undefined. + /// </summary> + /// <param name="_Array"> + /// A single-dimensional array with _Rank elements. + /// </param> + explicit extent(const int _Array[_Rank]) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAssign>::func(*this, _Array); + } + + /// <summary> + /// copy-assignment operator + /// </summary> + extent<_Rank>& operator=(const extent<_Rank>& _Other) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAssign>::func(*this, _Other); + return *this; + } + + /// <summary> + /// Index operator. + /// </summary> + /// <param name="_Index"> + /// An integral value between 0 and _Rank-1. + /// </param> + /// <returns> + /// The corresponding value stored at _Index. + /// </returns> + int operator[] (unsigned int _Index) const __GPU + { + return _M_base[_Index]; + } + + /// <summary> + /// Index operators. + /// </summary> + /// <param name="_Index"> + /// An integral value between 0 and _Rank-1. + /// </param> + /// <returns> + /// A reference to the value stored at _Index. + /// </returns> + int& operator[] (unsigned int _Index) __GPU + { + return _M_base[_Index]; + } + + /// <summary> + /// Returns the total linear size of this extent (in units of elements). + /// </summary> + unsigned int size() const __GPU + { + return static_cast<unsigned int>(_product_helper<extent<_Rank>>::func(_M_base)); + } + + /// <summary> + /// Tests whether the index "_Index" is properly contained within this extent. + /// </summary> + bool contains(const index<rank>& _Index) const __GPU + { + return details::_contains<extent<rank>, index<rank>, rank>::func(*this, _Index); + } + + /// <summary> + /// Produces a tiled_extent object with the tile extents given by _Dim0. + /// </summary> + template <int _Dim0> tiled_extent<_Dim0> tile() const __GPU + { + static_assert(rank == 1, "One-dimensional tile() method only available on extent<1>"); + static_assert(_Dim0>0, "All tile dimensions must be positive"); + + return tiled_extent<_Dim0>(*this); + } + + /// <summary> + /// Produces a tiled_extent object with the tile extents given by _Dim0, _Dim1 + /// </summary> + template <int _Dim0, int _Dim1> tiled_extent<_Dim0, _Dim1> tile() const __GPU + { + static_assert(rank == 2, "Two-dimensional tile() method only available on extent<2>"); + static_assert(_Dim0>0 && _Dim1>0, "All tile dimensions must be positive"); + + return tiled_extent<_Dim0, _Dim1>(*this); + } + + /// <summary> + /// Produces a tiled_extent object with the tile extents given by _Dim0, _Dim1, _Dim2. + /// </summary> + template <int _Dim0, int _Dim1, int _Dim2> tiled_extent<_Dim0, _Dim1, _Dim2> tile() const __GPU + { + static_assert(rank == 3, "Three-dimensional tile() method only available on extent<3>"); + static_assert(_Dim0>0 && _Dim1>0 && _Dim2>0, "All tile dimensions must be positive"); + + return tiled_extent<_Dim0, _Dim1, _Dim2>(*this); + } + + // Operations + + /// <summary> + /// Element-wise addition of this extent with an index. + /// </summary> + /// <param name="_Rhs"> + /// The index to add to this extent + /// </param> + /// <returns> + /// A new extent with the result of the computation. + /// </returns> + extent<_Rank> operator+(const index<_Rank>& _Rhs) __GPU + { + extent<_Rank> new_extent(details::_do_not_initialize); + details::_arithmetic_op_loop_helper<extent<_Rank>, details::opAdd>::func(new_extent, *this, _Rhs); + return new_extent; + } + + /// <summary> + /// Element-wise subtraction of this extent with an index. + /// </summary> + /// <param name="_Rhs"> + /// The index to subtract from this extent + /// </param> + /// <returns> + /// A new extent with the result of the computation. + /// </returns> + extent<_Rank> operator-(const index<_Rank>& _Rhs) __GPU + { + extent<_Rank> new_extent(details::_do_not_initialize); + details::_arithmetic_op_loop_helper<extent<_Rank>, details::opSub>::func(new_extent, *this, _Rhs); + return new_extent; + } + + /// <summary> + /// Element-wise addition of this extent with another extent. + /// </summary> + /// <param name="_Rhs"> + /// The extent to add + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator+=(const extent<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAddEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Element-wise subtraction of this extent with another extent. + /// </summary> + /// <param name="_Rhs"> + /// The extent to subtract + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator-=(const extent<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opSubEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Element-wise addition of this extent with an index. + /// </summary> + /// <param name="_Rhs"> + /// The index to add + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator+=(const index<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAddEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Element-wise subtraction of this extent with an index. + /// </summary> + /// <param name="_Rhs"> + /// The index to subtract + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator-=(const index<_Rank>& _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opSubEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Adds an integer value to each element of this extent. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to add to this extent + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator+=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAddEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Subtracts an integer value from each element of this extent. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to subtract from this extent + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator-=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opSubEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Multiplies an integer value to each element of this extent. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to multiply into this extent + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator*=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opMulEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Divides an integer value into each element of this extent. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to divide into this extent + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator/=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opDivEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Modulus an integer value from each element of this extent. + /// </summary> + /// <param name="_Rhs"> + /// The integer value to modulo this extent + /// </param> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator%=(int _Rhs) __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opModEq>::func(*this, _Rhs); + return *this; + } + + /// <summary> + /// Pre-increments each element of this extent. + /// </summary> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator++() __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAddEq>::func(*this, 1); + return *this; + } + + /// <summary> + /// Post-increments each element of this extent. + /// </summary> + /// <returns> + /// The value of the unincremented extent. + /// </returns> + extent<_Rank> operator++(int) __GPU + { + extent<_Rank> old_extent(*this); + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opAddEq>::func(*this, 1); + return old_extent; + } + + /// <summary> + /// Pre-decrements each element of this extent. + /// </summary> + /// <returns> + /// A reference to this extent. + /// </returns> + extent<_Rank>& operator--() __GPU + { + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opSubEq>::func(*this, 1); + return *this; + } + + /// <summary> + /// Post-decrements each element of this extent. + /// </summary> + /// <returns> + /// The value of the undecremented extent. + /// </returns> + extent<_Rank> operator--(int) __GPU + { + extent<_Rank> old_extent(*this); + details::_compound_assign_op_loop_helper<extent<_Rank>, details::opSubEq>::func(*this, 1); + return old_extent; + } + + // implementation details (compiler helpers) - begin + + // Index mapping for simple zero-based extent domain. + index<_Rank> _map_index(const index<_Rank>& _Index) const __GPU { + return _Index; + } + +private: + template<class _Tuple_type> + friend + _Tuple_type details::_Create_uninitialized_tuple() __GPU; + /// <summary> + /// Constructor. + /// </summary> + /// <param name=""> + /// Indicates that no initialization is necessary. + /// </param> + extent(details::_eInitializeState) __GPU {} + + // the store + int _M_base[_Rank]; +}; + +template <int _Rank, template <int> class _Tuple_type> +bool operator==(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + return details::_cmp_op_loop_helper<_Tuple_type<_Rank>, details::opEq>::func(_Lhs, _Rhs); +} + +template <int _Rank, template <int> class _Tuple_type> +bool operator!=(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + return !details::_cmp_op_loop_helper<_Tuple_type<_Rank>, details::opEq>::func(_Lhs, _Rhs); +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator+(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator-(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator+(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator+(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator-(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator-(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator*(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator*(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator/(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator/(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator%(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} + +template <int _Rank, template <int> class _Tuple_type> +_Tuple_type<_Rank> operator%(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU +{ + _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>(); + details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs); + return new_Tuple; +} +/// <summary> +/// The tile_barrier class is a capability class that is only creatable by +/// the system, and passed to a tiled parallel_for_each lambda as part of +/// the tiled_index parameter. It provides wait methods whose purpose is +/// to synchronize execution of threads running within the thread +/// group (tile). +/// </summary> +class tile_barrier +{ +public: + /// <summary> + /// Copy Constructor. The tile_barrier class does not have a public + /// default constructor or assignment operator, only copy-constructor. + /// </summary> + /// <param name="_Other"> + /// The tile_barrier instance to be copied from. + /// </param> +#pragma warning( suppress : 4100 ) // unreferenced formal parameter + tile_barrier(const tile_barrier& _Other) __GPU {} + + /// <summary> + /// Blocks execution of all threads in a tile until all all threads in the tile have reached this call. + /// Ensures that memory accesses are visible to other threads in the thread tile, and are executed according to program order + /// </summary> + void wait() const __GPU_ONLY + { + __dp_d3d_all_memory_fence_with_tile_barrier(); + } + + /// <summary> + /// Blocks execution of all threads in a tile until all all threads in the tile have reached this call. + /// Ensures that memory accesses are visible to other threads in the thread tile, and are executed according to program order + /// </summary> + void wait_with_all_memory_fence() const __GPU_ONLY + { + __dp_d3d_all_memory_fence_with_tile_barrier(); + } + + /// <summary> + /// Blocks execution of all threads in a tile until all all threads in the tile have reached this call. + /// Ensures that global memory accesses are visible to other threads in the thread tile, and are executed according to program order + /// </summary> + void wait_with_global_memory_fence() const __GPU_ONLY + { + __dp_d3d_device_memory_fence_with_tile_barrier(); + } + + /// <summary> + /// Blocks execution of all threads in a tile until all all threads in the tile have reached this call. + /// Ensures that tile_static memory accesses are visible to other threads in the thread tile, and are executed according to program order + /// </summary> + void wait_with_tile_static_memory_fence() const __GPU_ONLY + { + __dp_d3d_tile_static_memory_fence_with_tile_barrier(); + } +}; + +/// <summary> +/// A _Tiled_index_base is the base class of all three kinds of tiled_index to +/// share the common code. +/// </summary> +template <int _Rank> class _Tiled_index_base +{ +public: + + _CPP_AMP_VERIFY_RANK(_Rank, tiled_index); + + static const int rank = _Rank; + + /// <summary> + /// An index that represents the global index within an extent. + /// </summary> + const index<rank> global; + + /// <summary> + /// An index that represents the relative index within the current tile of a tiled_extent. + /// </summary> + const index<rank> local; + + /// <summary> + /// An index that represents the coordinates of the current tile of a tiled_extent. + /// </summary> + const index<rank> tile; + + /// <summary> + /// An index that represents the global coordinates of the origin of the current tile within a tiled_extent. + /// </summary> + const index<rank> tile_origin; + + /// <summary> + /// An object which represents a barrier within the current tile of threads. + /// </summary> + const tile_barrier barrier; + + /// <summary> + /// A Constructor that initializes data members using the given values. + /// </summary> + /// <param name="_Global"> + /// The global index to be copied from + /// </param> + /// <param name="_Local"> + /// The local index to be copied from + /// </param> + /// <param name="_Tile"> + /// The tile index to be copied from + /// </param> + /// <param name="_Tile_origin"> + /// The tile origin to be copied from + /// </param> + /// <param name="_Barrier"> + /// The barrier to be copied from + /// </param> + _Tiled_index_base(const index<rank>& _Global, + const index<rank>& _Local, + const index<rank>& _Tile, + const index<rank>& _Tile_origin, + const tile_barrier& _Barrier) __GPU + : global(_Global), local(_Local), tile(_Tile), tile_origin(_Tile_origin), barrier(_Barrier) + {} + + /// <summary> + /// Copy Constructor. + /// </summary> + /// <param name="_Other"> + /// The tile_index instance to be copied from . + /// </param> + _Tiled_index_base(const _Tiled_index_base& _Other) __GPU + : global(_Other.global), + local(_Other.local), + tile(_Other.tile), + tile_origin(_Other.tile_origin), + barrier(_Other.barrier) + {} + + /// <summary> + /// Implicit conversion operator that converts a tiled_index into an index. + /// The implicit conversion converts to the .global index member. + /// </summary> + operator const index<rank>() const __GPU + { + return global; + } + +private: + _Tiled_index_base& operator=(const _Tiled_index_base&) __GPU; +}; + +/// <summary> +/// A tiled_index is a set of indices of 1 to 3 dimensions which have been +/// subdivided into 1-, 2-, or 3-dimensional tiles in a tiled_extent. It has +/// three specialized forms: tiled_index<_Dim0>, tiled_index<_Dim0, _Dim1>, and +/// tiled_index<_Dim0, _Dim1, _Dim2>, where _Dim0-2 specify the length of the tile along +/// the each dimension, with _Dim0 being the most-significant dimension and _Dim2 +/// being the least-significant. +/// </summary> +template <int _Dim0, int _Dim1 = 0, int _Dim2 = 0> class tiled_index : public _Tiled_index_base<3> +{ +public: + /// <summary> + /// A Constructor that initializes data members using the given values. + /// </summary> + /// <param name="_Global"> + /// The global index to be copied from + /// </param> + /// <param name="_Local"> + /// The local index to be copied from + /// </param> + /// <param name="_Tile"> + /// The tile index to be copied from + /// </param> + /// <param name="_Tile_origin"> + /// The tile origin to be copied from + /// </param> + /// <param name="_Barrier"> + /// The barrier to be copied from + /// </param> + tiled_index(const index<rank>& _Global, + const index<rank>& _Local, + const index<rank>& _Tile, + const index<rank>& _Tile_origin, + const tile_barrier& _Barrier) __GPU + : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier) + {} + + /// <summary> + /// Copy Constructor. + /// </summary> + /// <param name="_Other"> + /// The tile_index instance to be copied from . + /// </param> + tiled_index(const tiled_index& _Other) __GPU + : _Tiled_index_base(_Other) + {} + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_index + /// template arguments _Dim0, _Dim1, _Dim2 + /// </summary> + __declspec(property(get=get_tile_extent)) extent<rank> tile_extent; + extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0, _Dim1, _Dim2); } + + /// <summary> + /// These constants allow access to the template arguments of tiled_index. + /// </summary> + static const int tile_dim0 = _Dim0; + static const int tile_dim1 = _Dim1; + static const int tile_dim2 = _Dim2; + +private: + tiled_index& operator=(const tiled_index&) __GPU; +}; + +template <int _Dim0, int _Dim1> +class tiled_index<_Dim0, _Dim1, 0> : public _Tiled_index_base<2> +{ +public: + /// <summary> + /// A Constructor that initializes data members using the given values. + /// </summary> + /// <param name="_Global"> + /// The global index to be copied from + /// </param> + /// <param name="_Local"> + /// The local index to be copied from + /// </param> + /// <param name="_Tile"> + /// The tile index to be copied from + /// </param> + /// <param name="_Tile_origin"> + /// The tile origin to be copied from + /// </param> + /// <param name="_Barrier"> + /// The barrier to be copied from + /// </param> + tiled_index(const index<rank>& _Global, + const index<rank>& _Local, + const index<rank>& _Tile, + const index<rank>& _Tile_origin, + const tile_barrier& _Barrier) __GPU + : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier) + {} + + /// <summary> + /// Copy Constructor. + /// </summary> + /// <param name="_Other"> + /// The tile_index instance to be copied from . + /// </param> + tiled_index(const tiled_index& _Other) __GPU + : _Tiled_index_base(_Other) + {} + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_index + /// template arguments _Dim0, _Dim1 + /// </summary> + __declspec(property(get=get_tile_extent)) extent<rank> tile_extent; + extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0, _Dim1); } + + /// <summary> + /// These constants allow access to the template arguments of tiled_index. + /// </summary> + static const int tile_dim0 = _Dim0; + static const int tile_dim1 = _Dim1; + +private: + tiled_index& operator=(const tiled_index&) __GPU; +}; + +template <int _Dim0> +class tiled_index<_Dim0, 0, 0> : public _Tiled_index_base<1> +{ +public: + /// <summary> + /// A Constructor that initializes data members using the given values. + /// </summary> + /// <param name="_Global"> + /// The global index to be copied from + /// </param> + /// <param name="_Local"> + /// The local index to be copied from + /// </param> + /// <param name="_Tile"> + /// The tile index to be copied from + /// </param> + /// <param name="_Tile_origin"> + /// The tile origin to be copied from + /// </param> + /// <param name="_Barrier"> + /// The barrier to be copied from + /// </param> + tiled_index(const index<rank>& _Global, + const index<rank>& _Local, + const index<rank>& _Tile, + const index<rank>& _Tile_origin, + const tile_barrier& _Barrier) __GPU + : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier) + {} + + /// <summary> + /// Copy Constructor. + /// </summary> + /// <param name="_Other"> + /// The tile_index instance to be copied from . + /// </param> + tiled_index(const tiled_index& _Other) __GPU + : _Tiled_index_base(_Other) + {} + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_index + /// template argument _Dim0 + /// </summary> + __declspec(property(get=get_tile_extent)) extent<rank> tile_extent; + extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0); } + + /// <summary> + /// These constants allow access to the template arguments of tiled_index. + /// </summary> + static const int tile_dim0 = _Dim0; + +private: + tiled_index& operator=(const tiled_index&) __GPU; +}; + + +/// <summary> +/// A tiled_extent is an extent of 1 to 3 dimensions which also subdivides the extent space into +/// 1-, 2-, or 3-dimensional tiles. It has three specialized forms: tiled_extent<_Dim0>, +/// tiled_extent<_Dim0,_Dim1>, and tiled_extent<_Dim0,_Dim1,_Dim2>, where _Dim0-2 specify the length of the tile +/// along each dimension, with _Dim0 being the most-significant dimension and _Dim2 being the +/// least-significant. +/// </summary> +template <int _Dim0, int _Dim1 /*=0*/, int _Dim2 /*=0*/> class tiled_extent : public Concurrency::extent<3> +{ +public: + + static_assert(_Dim0>0, "_Dim0 must be positive"); + static_assert(_Dim1>0, "_Dim1 must be positive"); + static_assert(_Dim2>0, "_Dim2 must be positive"); + + /// <summary> + /// Default constructor. + /// </summary> + tiled_extent() __GPU {} + + /// <summary> + /// Constructs a new tiled_extent from the supplied extent. + /// </summary> + tiled_extent(const Concurrency::extent<rank>& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other". + /// </summary> + tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// copy-assignment operator + /// </summary> + tiled_extent& operator=(const tiled_extent& _Other) __GPU + { + Concurrency::extent<rank>::operator=(_Other); + return *this; + } + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_extent + /// template arguments _Dim0, _Dim1, _Dim2. + /// </summary> + __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent; + Concurrency::extent<rank> get_tile_extent() const __GPU + { + return Concurrency::extent<rank>(_Dim0, _Dim1, _Dim2); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent pad() const __GPU + { + Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0, + ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1, + ((static_cast<unsigned int>((*this)[2]) + _Dim2 - 1)/_Dim2) * _Dim2); + + return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent truncate() const __GPU + { + Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1, ((*this)[2]/_Dim2) * _Dim2); + return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent); + } + + /// <summary> + /// These constants allow access to the template arguments of tiled_extent. + /// </summary> + static const int tile_dim0 = _Dim0; + static const int tile_dim1 = _Dim1; + static const int tile_dim2 = _Dim2; + + // implementation details (compiler helpers) - begin + + // Given the local index, the tile index, the global index, in the 0-based domain that + // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1, _Dim2> into + // the 'this' tiled_extent domain. + tiled_index<_Dim0, _Dim1, _Dim2> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU + { + index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>(); + details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent); + return tiled_index<_Dim0, _Dim1, _Dim2>(_Global, _Local, _Tile, _Tile_origin, _Barrier); + } + // implementation details (compiler helpers) - end +}; + + +template <int _Dim0, int _Dim1> +class tiled_extent<_Dim0, _Dim1, 0> : public Concurrency::extent<2> +{ +public: + + static_assert(_Dim0>0, "_Dim0 must be positive"); + static_assert(_Dim1>0, "_Dim1 must be positive"); + + /// <summary> + /// Default constructor. + /// </summary> + tiled_extent() __GPU {} + + /// <summary> + /// Constructs a new tiled_extent from the supplied extent. + /// </summary> + tiled_extent(const Concurrency::extent<rank>& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other". + /// </summary> + tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// copy-assignment operator + /// </summary> + tiled_extent& operator=(const tiled_extent& _Other) __GPU + { + Concurrency::extent<rank>::operator=(_Other); + return *this; + } + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_extent + /// template arguments _Dim0, _Dim1. + /// </summary> + __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent; + Concurrency::extent<rank> get_tile_extent() const __GPU + { + return Concurrency::extent<rank>(_Dim0, _Dim1); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent pad() const __GPU + { + Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0, + ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1); + return tiled_extent<_Dim0,_Dim1>(_New_extent); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent truncate() const __GPU + { + Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1); + return tiled_extent<_Dim0,_Dim1>(_New_extent); + } + + /// <summary> + /// These constants allow access to the template arguments of tiled_extent. + /// </summary> + static const int tile_dim0 = _Dim0; + static const int tile_dim1 = _Dim1; + + // implementation details (compiler helpers) - begin + + // Given the local index, the tile index, the global index, in the 0-based domain that + // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1> into + // the 'this' tiled_extent domain. + tiled_index<_Dim0, _Dim1> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU + { + index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>(); + details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent); + return tiled_index<_Dim0, _Dim1>(_Global, _Local, _Tile, _Tile_origin, _Barrier); + } + // implementation details (compiler helpers) - end +}; + +template <int _Dim0> +class tiled_extent<_Dim0, 0, 0> : public Concurrency::extent<1> +{ +public: + + static_assert(_Dim0>0, "_Dim0 must be positive"); + + /// <summary> + /// Default constructor. + /// </summary> + tiled_extent() __GPU {} + + /// <summary> + /// Constructs a new tiled_extent from the supplied extent. + /// </summary> + tiled_extent(const Concurrency::extent<rank>& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other". + /// </summary> + tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other) + {} + + /// <summary> + /// copy-assignment operator + /// </summary> + tiled_extent& operator=(const tiled_extent& _Other) __GPU + { + Concurrency::extent<rank>::operator=(_Other); + return *this; + } + + /// <summary> + /// Returns an instance of an extent that captures the values of the tiled_extent + /// template argument _Dim0. + /// </summary> + __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent; + Concurrency::extent<rank> get_tile_extent() const __GPU + { + return Concurrency::extent<rank>(_Dim0); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent pad() const __GPU + { + Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0); + return tiled_extent<_Dim0>(_New_extent); + } + + /// <summary> + /// Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions. + /// </summary> + tiled_extent truncate() const __GPU + { + Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0); + return tiled_extent<_Dim0>(_New_extent); + } + + /// <summary> + /// These constants allow access to the template arguments of tiled_extent. + /// </summary> + static const int tile_dim0 = _Dim0; + + // implementation details (compiler helpers) - begin + + // Given the local index, the tile index, the global index, in the 0-based domain that + // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0> into + // the 'this' tiled_extent domain. + tiled_index<_Dim0> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU + { + index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>(); + details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent); + return tiled_index<_Dim0>(_Global, _Local, _Tile, _Tile_origin, _Barrier); + } +}; + +namespace details +{ + +template <int _Old_element_size, int _New_element_size> +int _Calculate_reinterpreted_size(int _Old_size) __GPU_ONLY +{ + int _Total_size = _Old_element_size * _Old_size; + int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size; + + return _New_size; +} + + +template <int _Old_element_size, int _New_element_size> +int _Calculate_reinterpreted_size(int _Old_size) __CPU_ONLY +{ + int _Total_size = _Old_element_size * _Old_size; + int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size; + + if (_New_size * _New_element_size > _Total_size) + throw runtime_exception("Element type of reinterpret_as does not evenly divide into extent", E_INVALIDARG); + + return _New_size; +} + + +// This class defines the shape of an array view and provides +// the functionality of translating dimensional indices into +// flat offsets into the underlying buffer +template <int _Rank, int _Element_size /* in number of ints */> +class _Array_view_shape +{ + typedef _Array_flatten_helper<_Rank, typename Concurrency::extent<_Rank>::value_type, typename Concurrency::index<_Rank>::value_type> _Flatten_helper; + friend class _Array_view_shape<_Rank+1, _Element_size>; + +public: + /// <summary> + /// The extent of this array or view. + /// </summary> + __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent; + Concurrency::extent<_Rank> get_extent() const __GPU + { + return _M_view_extent; + } + + ~_Array_view_shape() __GPU {} + +protected: + int _Base_linear_offset() const __GPU + { + return (_M_total_linear_offset - (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base))); + } + + _Array_view_shape(const _Array_view_shape& _Other) __GPU + : + _M_array_extent(_Other._M_array_extent), + _M_array_multiplier(_Other._M_array_multiplier), + _M_view_offset(_Other._M_view_offset), + _M_total_linear_offset(_Other._M_total_linear_offset), + _M_view_extent(_Other._M_view_extent) + { + } + + // For "section" + _Array_view_shape(const _Array_view_shape& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + : + _M_array_extent(_Other._M_array_extent), + _M_array_multiplier(_Other._M_array_multiplier), + _M_view_offset(_Other._M_view_offset + _Section_origin), + _M_view_extent(_Section_extent) + { + _Is_valid_section(_Other._M_view_extent, _Section_origin, _Section_extent); + + _M_total_linear_offset = _Other._Base_linear_offset() + (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base)); + } + + _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU + : + _M_array_extent(_Array_extent), + _M_view_offset(index<_Rank>()), + _M_total_linear_offset(_Base_linear_offset), + _M_view_extent(_Array_extent) + { + _Initialize_multiplier(); + } + + _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent, + const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + : + _M_array_extent(_Array_extent), + _M_view_offset(_Section_origin), + _M_total_linear_offset(_Base_linear_offset), + _M_view_extent(_Section_extent) + { + _Is_valid_section(_Array_extent, _Section_origin, _Section_extent); + + _Initialize_multiplier(); + _M_total_linear_offset += (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base)); + } + + _Array_view_shape& operator=(const _Array_view_shape &_Other) __GPU + { + _M_array_extent = _Other._M_array_extent; + _M_array_multiplier = _Other._M_array_multiplier; + _M_view_offset = _Other._M_view_offset; + _M_total_linear_offset = _Other._M_total_linear_offset; + _M_view_extent = _Other._M_view_extent; + return *this; + } + + void _Project0(int _I, _Array_view_shape<_Rank-1,_Element_size>& _Projected_shape) const __GPU + { + static_assert(_Rank > 1, "Projection is only supported on array_views with a rank of 2 or higher"); + + _Is_valid_projection(_I, this->_M_view_extent); + + typedef Concurrency::extent<_Rank-1> _RES_EXT; + typedef Concurrency::extent<_Rank> _SRC_EXT; + typedef Concurrency::index<_Rank-1> _RES_IDX; + typedef Concurrency::index<_Rank> _SRC_IDX; + details::_project0<_RES_EXT, _SRC_EXT, _RES_IDX, _SRC_IDX, _Rank>::func( + _Projected_shape._M_array_extent, this->_M_array_extent, + _Projected_shape._M_array_multiplier, this->_M_array_multiplier, + _Projected_shape._M_view_offset, this->_M_view_offset, + _Projected_shape._M_view_extent, this->_M_view_extent); + + _Projected_shape._M_total_linear_offset = _M_total_linear_offset + (_Element_size * _I * _M_array_multiplier[0]); + } + + _Array_view_shape() __GPU + : _M_array_extent(details::_do_not_initialize), _M_array_multiplier(details::_do_not_initialize), + _M_view_offset(details::_do_not_initialize), _M_view_extent(details::_do_not_initialize) + { + } + +private: + + void _Initialize_multiplier() __GPU + { + details::_Is_valid_extent(_M_array_extent); + unsigned int _Ext = _M_array_extent[_Rank-1]; + details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(_Ext, _M_array_multiplier, _M_array_extent); + } + +protected: + Concurrency::extent<_Rank> _M_array_extent; + Concurrency::extent<_Rank> _M_array_multiplier; + Concurrency::index<_Rank> _M_view_offset; + int _M_total_linear_offset; // in number of units + Concurrency::extent<_Rank> _M_view_extent; +}; + +template <int _Rank, int _Element_size> +class _Array_view_base : public _Array_view_shape<_Rank,_Element_size /* in number of ints */> +{ + template <int _R, int _S> + friend class _Array_view_base; + +public: + + typedef details::_Buffer_descriptor _Buffer_descriptor; + + ~_Array_view_base() __GPU + { + // Unregister the view; Do not throw exception + _Unregister(false); + } + +protected: + + _Array_view_base() __GPU {} + + _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const _Array_view_shape& _Shape) __GPU + : + _M_buffer_descriptor(_Buffer_desc), + _Array_view_shape<_Rank, _Element_size>(_Shape) + { + // Register the view + _Register(); + } + + _Array_view_base(const _Array_view_base& _Other) __GPU + : + _M_buffer_descriptor(_Other._M_buffer_descriptor), + _Array_view_shape<_Rank, _Element_size>(_Other) + { + // Register the view + _Register_copy(_Other); + } + + _Array_view_base(const _Array_view_base& _Other, const Concurrency::extent<_Rank>& _Array_extent) __GPU + : + _M_buffer_descriptor(_Other._M_buffer_descriptor), + _Array_view_shape<_Rank, _Element_size>(_Other._Base_linear_offset(), _Array_extent) + { + // Register the view + _Register(); + } + + _Array_view_base(const _Array_view_base& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + : + _M_buffer_descriptor(_Other._M_buffer_descriptor), + _Array_view_shape<_Rank, _Element_size>(_Other, _Section_origin, _Section_extent) + { + // Register the view + _Register(); + } + + _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent) __GPU + : + _M_buffer_descriptor(_Buffer_desc), + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent) + { + // Register the view + _Register(); + } + + _Array_view_base(const _Buffer_descriptor& _Buffer_desc, int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU + : + _M_buffer_descriptor(_Buffer_desc), + _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent) + { + // Register the view + _Register(); + } + + _Array_view_base( + const _Buffer_descriptor& _Buffer_desc, + int _Base_linear_offset, + const Concurrency::extent<_Rank>& _Array_extent, + const Concurrency::index<_Rank>& _View_offset, + const Concurrency::extent<_Rank>& _View_extent + ) __GPU + : + _M_buffer_descriptor(_Buffer_desc), + _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent,_View_offset,_View_extent) + { + // Register the view + _Register(); + } + + _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent, + const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + : + _M_buffer_descriptor(_Buffer_desc), + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent,_Section_origin,_Section_extent) + { + // Register the view + _Register(); + } + + _Array_view_base(const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY + : + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent) + { + _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Array_extent.size(), _Element_size * sizeof(int)); + _M_buffer_descriptor = _Buffer_descriptor(NULL, _PUBuf, _No_access, _No_access); + + // Register the view + _Register(); + } + + _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY + : + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent) + { + if (_Data == NULL) { + throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG); + } + + _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Data, accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int)); + _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf); + _M_buffer_descriptor = _Buffer_descriptor(_Data, _PUBuf, _Read_write_access, _Read_write_access); + + // Register the view + _Register(); + } + + _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY + : + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(_Data, NULL, _Read_write_access, _Read_write_access) + { + } + + _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY + : + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent) + { + if (_Data == NULL) { + throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG); + } + + _Buffer_ptr _PBuf = _Buffer::_Create_buffer(const_cast<void*>(_Data), accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int)); + _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf); + _M_buffer_descriptor = _Buffer_descriptor(const_cast<void*>(_Data), _PUBuf, _Read_access, _Read_access); + + // Register the view + _Register(); + } + + _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY + : +#pragma warning( push ) +#pragma warning( disable : 4880 ) + // Casting away constness in amp restricted scope might result in + // undefined behavior, therefore, the compiler will report a level 1 warning + // for it. But the following const_cast is harmless thus we are suppressing + // this warning just for this line. + _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(const_cast<void*>(_Data), NULL, _Read_access, _Read_access) +#pragma warning( pop ) + { + } + + _Array_view_base& operator=(const _Array_view_base &_Other) __GPU + { + if (this != &_Other) + { + // Unregister the current view + _Unregister(); + + _M_buffer_descriptor = _Other._M_buffer_descriptor; + _Array_view_shape<_Rank, _Element_size>::operator=(_Other); + + // Register the new view + _Register_copy(_Other); + } + + return *this; + } + + _Ret_ void * _Access(const index<_Rank>& _Index) const __GPU + { + int * _Ptr = reinterpret_cast<int *>(_M_buffer_descriptor._M_data_ptr); + return &_Ptr[_M_total_linear_offset + (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _Index._M_base))]; + } + + _Ret_ void * _Access(_Access_mode _Requested_mode, const index<_Rank>& _Index) const __CPU_ONLY + { + // Refresh the data ptr if we do not have requested access + if ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode) { + _M_buffer_descriptor._Get_CPU_access(_Requested_mode); + } + + return _Access(_Index); + } + + _Ret_ void * _Access(_Access_mode _Requested_mode, const index<_Rank>& _Index) const __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Requested_mode); + + return _Access(_Index); + } + + _Array_view_base _Section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU + { + auto _View = _Array_view_base(*this, _Section_origin, _Section_extent); + + // Register the constructed view with the section buffer view shape + _View._Register(_Array_view_base::_Create_section_buffer_shape(this->_M_buffer_descriptor, _Section_origin, _Section_extent)); + + return _View; + } + + _Array_view_base _Section(const index<_Rank>& _Idx) const __GPU + { + return _Section(_Idx, this->extent - _Idx); + } + + void _Project0(int _I, _Array_view_base<_Rank-1,_Element_size>& _Projected_view) const __GPU + { + _Projected_view._M_buffer_descriptor = this->_M_buffer_descriptor; + _Array_view_shape<_Rank, _Element_size>::_Project0(_I, _Projected_view); + + // Register the constructed view with the projection buffer view shape + _Projected_view._Register(_Array_view_base::_Create_projection_buffer_shape(this->_M_buffer_descriptor, 0, _I)); + } + + template <int _New_element_size> + _Array_view_base<_Rank,_New_element_size> _Reinterpret_as() const __GPU + { + static_assert(_Rank==1, "reinterpret_as is only permissible on array views of rank 1"); + int _New_size = _Calculate_reinterpreted_size<_Element_size,_New_element_size>(_M_view_extent.size()); + return _Array_view_base<_Rank,_New_element_size>(this->_M_buffer_descriptor, + _M_total_linear_offset, + Concurrency::extent<_Rank>(_New_size)); + } + + template <int _New_rank> + _Array_view_base<_New_rank, _Element_size> _View_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU + { + static_assert(_Rank==1, "view_as is only permissible on array views of rank 1"); + return _Array_view_base<_New_rank, _Element_size>(this->_M_buffer_descriptor, + _M_total_linear_offset, + _View_extent, + index<_New_rank>(), + _View_extent); + } + + _Ret_ _View_shape* _Create_buffer_view_shape() const __CPU_ONLY + { + unsigned int bufElemSize = static_cast<unsigned int>(_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size()); + unsigned int elemSize = _Element_size * sizeof(int); + + size_t linearOffsetInBytes = _Base_linear_offset() * sizeof(int); + + size_t baseLSDExtentInBytes = _M_array_extent[_Rank - 1]; + baseLSDExtentInBytes *= elemSize; + + size_t viewLSDOffsetInBytes = _M_view_offset[_Rank - 1]; + viewLSDOffsetInBytes *= elemSize; + + size_t viewLSDExtentInBytes = _M_view_extent[_Rank - 1]; + viewLSDExtentInBytes *= elemSize; + + // The base array extent, view extent, and view offset must be compatible with the underlying + // buffer's element size + if (((linearOffsetInBytes % bufElemSize) != 0) || + ((baseLSDExtentInBytes % bufElemSize) != 0) || + ((viewLSDOffsetInBytes % bufElemSize) != 0) || + ((viewLSDExtentInBytes % bufElemSize) != 0)) + { + throw runtime_exception("The array_view base extent, view offset and/or view extent is incompatible with the underlying buffer", E_FAIL); + } + + // The shape to be passed to the underlying buffer for registration must be in terms of + // the element size of the buffer + _ASSERTE((linearOffsetInBytes / bufElemSize) <= UINT_MAX); + unsigned int linearOffset = static_cast<unsigned int>(linearOffsetInBytes / bufElemSize); + + unsigned int baseExtent[_Rank]; + unsigned int viewOffset[_Rank]; + unsigned int viewExtent[_Rank]; +#pragma warning( push ) +#pragma warning( disable : 6294 ) +#pragma warning( disable : 6201 ) // Index '-1' is out of valid index range '0' to '0' for possibly stack allocated buffer 'baseExtent'. + for (int i = 0; i < _Rank - 1; ++i) { + baseExtent[i] = _M_array_extent[i]; + viewOffset[i] = _M_view_offset[i]; + viewExtent[i] = _M_view_extent[i]; + } +#pragma warning( pop ) + + // The extent in the least significant dimension needs to be adjusted for + // difference in element size between the buffer and ourselves + _ASSERTE((baseLSDExtentInBytes / bufElemSize) <= UINT_MAX); + baseExtent[_Rank - 1] = static_cast<unsigned int>(baseLSDExtentInBytes / bufElemSize); + + _ASSERTE((viewLSDOffsetInBytes / bufElemSize) <= UINT_MAX); + viewOffset[_Rank - 1] = static_cast<unsigned int>(viewLSDOffsetInBytes / bufElemSize); + + _ASSERTE((viewLSDExtentInBytes / bufElemSize) <= UINT_MAX); + viewExtent[_Rank - 1] = static_cast<unsigned int>(viewLSDExtentInBytes / bufElemSize); + + return _View_shape::_Create_view_shape(_Rank, linearOffset, baseExtent, viewOffset, viewExtent); + } + +protected: + + // Underlying storage + _Buffer_descriptor _M_buffer_descriptor; + +private: + + void _Register() __CPU_ONLY + { + _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(), + accelerator(accelerator::cpu_accelerator).default_view, + _Create_buffer_view_shape()); + + if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access) + { + _Buffer_ptr _PBuf; + _Get_access_async(_M_buffer_descriptor._Get_view_key(), + accelerator(accelerator::cpu_accelerator).default_view, + _M_buffer_descriptor._M_curr_cpu_access_mode, + _PBuf)._Get(); + + _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr(); + } + } + + void _Register_copy(const _Array_view_base &_Other) __CPU_ONLY + { + _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key()); + } + + void _Register(_In_ void* _Shape) __CPU_ONLY + { + if (_Shape == NULL) { + return; + } + + // Unregister and register with the right shape + _Unregister(); + + _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(), + accelerator(accelerator::cpu_accelerator).default_view, + reinterpret_cast<_View_shape*>(_Shape)); + + if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access) + { + _Buffer_ptr _PBuf; + _Get_access_async(_M_buffer_descriptor._Get_view_key(), + accelerator(accelerator::cpu_accelerator).default_view, + _M_buffer_descriptor._M_curr_cpu_access_mode, + _PBuf)._Get(); + + _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr(); + } + } + + void _Unregister(bool _Throw_exception = true) __CPU_ONLY + { + if (!_Throw_exception && (std::current_exception() == nullptr)) { + _Throw_exception = true; + } + + try + { + _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key()); + } + catch(...) + { + if (_Throw_exception) { + throw; + } + } + } + + static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& _Descriptor, unsigned int _Dim, int _Dim_offset) __CPU_ONLY + { + _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor); + + std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank()); + std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank()); + bool *_New_projection_info = new bool[_Base_shape->_Get_rank()]; + for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I) + { + _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I]; + _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I]; + _New_projection_info[_I] = _Base_shape->_Get_projection_info()[_I]; + } + + // The _Dim'th non-projected dimension needs to be found + unsigned int _UnProjectedDimCount = 0; + for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I) + { + if (_Base_shape->_Get_projection_info()[_I]) { + continue; + } + + if (_UnProjectedDimCount == _Dim) { + _New_view_extent[_I] = 1; + _New_view_offset[_I] += _Dim_offset; + _New_projection_info[_I] = true; + break; + } + else { + _UnProjectedDimCount++; + } + } + + auto _PView_shape = _View_shape::_Create_view_shape(_Base_shape->_Get_rank(), + _Base_shape->_Get_linear_offset(), + _Base_shape->_Get_base_extent(), + _New_view_offset.data(), + _New_view_extent.data(), + _New_projection_info); + + delete [] _New_projection_info; + + return _PView_shape; + } + + static _Ret_ void* _Create_section_buffer_shape(const _Buffer_descriptor& _Descriptor, + const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __CPU_ONLY + { + _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor); + if (_Base_shape->_Get_rank() == _Rank) { + return NULL; + } + + std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank()); + std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank()); + unsigned int _I = 0, _J = 0; + while (_I < _Base_shape->_Get_rank()) + { + if (_Base_shape->_Get_projection_info()[_I]) + { + _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I]; + _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I]; + } + else + { + // If _J is the least significant dimension, then we need to adjust the + // offset and extent for the underlying buffer's element size + if (_J == (_Rank - 1)) + { + unsigned int bufElemSize = static_cast<unsigned int>(_Descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size()); + unsigned int elemSize = _Element_size * sizeof(int); + + size_t sectionLSDOriginInBytes = _Section_origin[_J]; + sectionLSDOriginInBytes *= elemSize; + + size_t sectionLSDExtentInBytes = _Section_extent[_J]; + sectionLSDExtentInBytes *= elemSize; + + // The section offset and extent must be compatible with the underlying + // buffer's element size + if (((sectionLSDOriginInBytes % bufElemSize) != 0) || + ((sectionLSDExtentInBytes % bufElemSize) != 0)) + { + throw runtime_exception("The array_view section origin and/or extent is incompatible with the underlying buffer", E_FAIL); + } + + // The extent in the least significant dimension needs to be adjusted for + // difference in element size between the buffer and ourselves + _ASSERTE((sectionLSDOriginInBytes / bufElemSize) <= UINT_MAX); + _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + static_cast<unsigned int>(sectionLSDOriginInBytes / bufElemSize); + + _ASSERTE((sectionLSDExtentInBytes / bufElemSize) <= UINT_MAX); + _New_view_extent[_I] = static_cast<unsigned int>(sectionLSDExtentInBytes / bufElemSize); + } + else + { + _New_view_extent[_I] = _Section_extent[_J]; + _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + _Section_origin[_J]; + } + + _J++; + } + + _I++; + } + + _ASSERTE(_J == _Rank); + + return _View_shape::_Create_view_shape(_Base_shape->_Get_rank(), + _Base_shape->_Get_linear_offset(), + _Base_shape->_Get_base_extent(), + _New_view_offset.data(), + _New_view_extent.data(), + _Base_shape->_Get_projection_info()); + } + + void _Register() __GPU_ONLY {} + + void _Register_copy(const _Array_view_base &_Other) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Other); + } + + void _Register(_In_ void* _Shape) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Shape); + } + + void _Unregister(bool _Throw_exception = true) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Throw_exception); + } + + static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& _Descriptor, int _Dim, int _I) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Descriptor); + UNREFERENCED_PARAMETER(_Dim); + UNREFERENCED_PARAMETER(_I); + + return NULL; + } + + static _Ret_ void* _Create_section_buffer_shape(const _Buffer_descriptor& _Descriptor, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Descriptor); + UNREFERENCED_PARAMETER(_Section_origin); + UNREFERENCED_PARAMETER(_Section_extent); + + return NULL; + } +}; + +template<typename _Container> +struct _Is_container +{ + template<class _Uty> static auto _Fn(_Uty _Val, decltype(_Val.size(), _Val.data(), 0)) -> std::true_type; + template<class _Uty> static auto _Fn(_Uty _Val, ...) -> std::false_type; + typedef decltype(_Fn(std::declval<_Container>(),0)) type; +}; + +} // namespace details + + +/// <summary> +/// An array_view is an N-dimensional view over data held in another container (such as array<T,N> +/// or other container. It exposes an indexing interface congruent to that of array<T,N>). +/// </summary> +/// <param name="_Rank"> +/// The number of dimensions of this array_view. +/// </param> +/// <param name="_Value_type"> +/// The type of the element. +/// </param> +template <typename _Value_type, int _Rank = 1> class array_view : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> +{ + typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base; + + _CPP_AMP_VERIFY_RANK(_Rank, array_view); + static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array views"); + + friend class details::_Array_view_projection_helper<_Value_type,_Rank>; + friend class details::_Array_view_projection_helper<_Value_type,_Rank+1>; + + friend class array_view<_Value_type, _Rank>; + friend class array_view<const _Value_type, _Rank>; + + friend class array_view<_Value_type, _Rank+1>; + friend class array_view<const _Value_type, _Rank+1>; + + template <typename _T, int _R> + friend class array; + + friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<_Value_type, _Rank>>(const array_view<_Value_type, _Rank>& _Array) __GPU; + +public: + static const int rank = _Rank; + typedef typename _Value_type value_type; + + + /// <summary> + /// Destroys this array_view and reclaims resources. + /// </summary> + ~array_view() __GPU {} + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src array. The extent of the + /// array_view is that of the _Src array, and the origin of the array view is at zero. + /// </summary> + /// <param name="_Src"> + /// An array which contains the data that this array_view is bound to. + /// </param> + array_view(array<_Value_type,_Rank>& _Src) __GPU + : _Base(_Get_buffer_descriptor(_Src), _Src.extent) + { + _Initialize(); + } + + /// <summary> + /// Copy constructor. Shallow copy. + /// </summary> + array_view(const array_view& _Other) __GPU + : _Base(_Other) + { + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is not bound to a data source. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + explicit array_view(const Concurrency::extent<_Rank>& _Extent) __CPU_ONLY + :_Base(_Extent) + { + _Initialize(_Extent.size(), true); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY + :_Base(_Src.data(),_Extent) + { + static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A pointer to the source data this array_view will bind to. If the number of elements pointed to + /// by _Src is less than the size of _Extent, undefined behavior results. + /// </param> + array_view(const Concurrency::extent<_Rank>& _Extent, _Value_type * _Src) __GPU + :_Base(_Src,_Extent) + { + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is not bound to a data source. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + explicit array_view(int _E0) __CPU_ONLY + :_Base(Concurrency::extent<1>(_E0)) + { + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(get_extent().size(), true); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + //// The length of the array_view is the same as the length of the container + /// </summary> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> explicit array_view(_Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size()))) + { + if (_Src.size() > INT_MAX) { + throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG); + } + static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> explicit array_view(int _E0, _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<1>(_E0)) + { + static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is not bound to a data source. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + explicit array_view(int _E0, int _E1) __CPU_ONLY + :_Base(Concurrency::extent<2>(_E0,_E1)) + { + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(get_extent().size(), true); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> explicit array_view(int _E0, int _E1, _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1)) + { + static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match"); + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is not bound to a data source. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + explicit array_view(int _E0, int _E1, int _E2) __CPU_ONLY + :_Base(Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(get_extent().size(), true); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> explicit array_view(int _E0, int _E1, int _E2, _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match"); + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0, undefined behavior results. + /// </param> + explicit array_view(int _E0, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<1>(_E0)) + { + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the array _Src. + /// </summary> + /// <param name="_Src"> + /// An array which contains the data that this array_view is bound to. + /// </param> + template <typename _Arr_type, int _Size> explicit array_view(_In_ _Arr_type (&_Src) [_Size]) __GPU + :_Base(_Src, Concurrency::extent<1>(_Size)) + { + static_assert( std::is_same<typename std::remove_reference<decltype(*_Src)>::type, _Value_type>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1, undefined behavior results. + /// </param> + explicit array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<2>(_E0,_E1)) + { + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1*_E2, undefined behavior results. + /// </param> + explicit array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(); + } + + /// <summary> + /// Copy Assignment operator. Shallow copy. + /// </summary> + array_view& operator=(const array_view& _Other) __GPU + { + _Base::operator=(_Other); + return *this; + } + + /// <summary> + /// Copies elements from this array_view to the destination array. + /// </summary> + void copy_to(array<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + copy(*this,_Dest); + } + + /// <summary> + /// Copies elements from this array_view to the destination array_view. + /// </summary> + void copy_to(const array_view<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + copy(*this,_Dest); + } + + /// <summary> + /// Projects the most-significant dimension of this array_view. If the array_view rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Result_type operator[] (int _I) const __GPU + { + return details::_Array_view_projection_helper<_Value_type,_Rank>::_Project0(this, _I); + } + + /// <summary> + /// Get a reference to the element indexed by _Index. Unlike the other indexing operators for accessing the + /// array_view on the CPU, this method does not implicitly synchronize this array_view's contents to the CPU. + /// After accessing the array_view on a remote location or performing a copy operation involving this array_view + /// users are responsible to explicitly synchronize the array_view to the CPU before calling this method. + /// Failure to do so results in undefined behavior. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// Reference to the element indexed by _Index + /// </returns> + value_type& get_ref(const index<_Rank>& _Index) const __GPU + { + void *_Ptr = _Access(_Index); + return *reinterpret_cast<value_type*>(_Ptr); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator[] (const index<_Rank>& _Index) const __GPU + { + return this->operator()(_Index); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator() (const index<_Rank>& _Index) const __GPU + { + void * _Ptr = _Access(_Read_write_access, _Index); + return *reinterpret_cast<value_type*>(_Ptr); + } + + /// <summary> + /// Projects the most-significant dimension of this array_view. If the array_view rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Result_type operator() (int _I) const __GPU + { + return details::_Array_view_projection_helper<_Value_type,_Rank>::_Project0(this, _I); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + value_type& operator() (int _I0, int _I1) const __GPU + { + static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>"); + return this->operator()(index<2>(_I0,_I1)); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + value_type& operator() (int _I0, int _I1, int _I2) const __GPU + { + static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>"); + return this->operator()(index<3>(_I0,_I1,_I2)); + } + + /// <summary> + /// Produces a subsection of the source array_view at the given origin and extent. + /// </summary> + /// <param name="_Section_origin"> + /// The origin of the section. + /// </param> + /// <param name="_Section_extent"> + /// The extent of the section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU + { + return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent)); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin specified by an index, with + /// an extent of (this->exent - _Idx). + /// </summary> + /// <param name="_Idx"> + /// The index that specifies the origin of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::index<_Rank>& _Idx) const __GPU + { + return section(_Idx, this->extent - _Idx); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin of zero, with + /// an extent of _Ext. + /// </summary> + /// <param name="_Ext"> + /// The extent of this section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::extent<_Rank>& _Ext) const __GPU + { + return section(Concurrency::index<_Rank>(), _Ext); + } + + /// <summary> + /// Produces a one-dimensional subsection of the source array_view with origin specified by the index + /// components _I0, with extent _E0. + /// </summary> + /// <param name="_I0"> + /// The origin of this section. + /// </param> + /// <param name="_E0"> + /// The extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _E0) const __GPU + { + static_assert(_Rank == 1, "rank must be 1"); + return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0)); + } + + /// <summary> + /// Produces a two-dimensional subsection of the source array_view with origin specified by the index + /// components (_I0,_I1), with extent (_E0,_E1). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU + { + static_assert(_Rank == 2, "rank must be 2"); + return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1)); + } + + /// <summary> + /// Produces a three-dimensional subsection of the source array_view with origin specified by the index + /// components (_I0,_I1,_I2), with extent (_E0,_E1,_E2). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the origin of this section. + /// </param> + /// <param name="_I2"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The next-to-most-significant component of the extent of this section. + /// </param> + /// <param name="_E2"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU + { + static_assert(_Rank == 3, "rank must be 3"); + return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2)); + } + + /// <summary> + /// Produces a (possibly unsafe) reinterpretation of this array_view that is linear and with + /// a different element type. The size of _Value_type2 must evenly divide into the size of + /// this array. + /// </summary> + /// <returns> + /// A linear array_view with a reinterpreted element type. + /// </returns> + template <typename _Value_type2> array_view<_Value_type2, _Rank> reinterpret_as() const __GPU + { + return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>()); + } + + /// <summary> + /// Produces an array_view of a different rank over this array_view's data. + /// </summary> + /// <param name="_View_extent"> + /// The reshaping extent. + /// </param> + /// <returns> + /// A reshaped array_view. + /// </returns> + template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU + { + return _Convert<_Value_type>(_View_as(_View_extent)); + } + + /// <summary> + /// Returns a pointer to the raw data of this array_view. + /// </summary> + _Ret_ _Value_type* data() const __GPU + { + static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>"); + return &this->operator[](index<_Rank>()); + } + + /// <summary> + /// Informs the array_view that its bound memory has been modified outside + /// the array_view interface. This will render all cached information stale. + /// </summary> + void refresh() const __CPU_ONLY + { + // If the array_view corresponds to a ubiquitous buffer with no data source, + // then refresh is a no-op + if (!_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) { + return; + } + + _Buffer_ptr _PBuf; + _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get(); + } + + /// <summary> + /// Asynchronously synchronizes any modifications made to "this" array_view to the specified accelerator_view. + /// </summary> + /// <param name="_Accl_view"> + /// The target accelerator_view to synchronize to. + /// </param> + /// <param name="_Access_type"> + /// The desired access_type on the target accelerator_view. + /// This parameter has a default value of access_type_read. + /// </param> + /// <returns> + /// A future upon which to wait for the operation to complete. + /// </returns> + concurrency::completion_future synchronize_to_async(const accelerator_view& _Accl_view, access_type _Access_type = access_type_read) const __CPU_ONLY + { + auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + _Event _Ev; + + if (_Access_type != access_type_none) { + _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf); + } + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); + } + + /// <summary> + /// Asynchronously synchronizes any modifications made to "this" array_view to its source data. + /// </summary> + /// <param name="_Access_type"> + /// The desired access_type on the target accelerator_view. + /// This parameter has a default value of access_type_read. + /// </param> + /// <returns> + /// A future upon which to wait for the operation to complete. + /// </returns> + concurrency::completion_future synchronize_async(access_type _Access_type = access_type_read) const __CPU_ONLY + { + auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + _Event _Ev; + + // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op + if ((_Access_type != access_type_none) && _M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) + { + _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), + _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), + _Get_synchronize_access_mode(_Access_type), + _PBuf); + } + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); + } + + /// <summary> + /// Synchronizes any modifications made to "this" array_view to the specified accelerator_view. + /// </summary> + /// <param name="_Accl_view"> + /// The target accelerator_view to synchronize to. + /// </param> + /// <param name="_Access_type"> + /// The desired access_type on the target accelerator_view. + /// This parameter has a default value of access_type_read. + /// </param> + void synchronize_to(const accelerator_view& _Accl_view, access_type _Access_type = access_type_read) const __CPU_ONLY + { + auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + + if (_Access_type != access_type_none) { + _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf)._Get(); + } + + details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Synchronizes any modifications made to "this" array_view to its source data. + /// </summary> + /// <param name="_Access_type"> + /// The desired access_type on the target accelerator_view. + /// This parameter has a default value of access_type_read. + /// </param> + void synchronize(access_type _Access_type = access_type_read) const __CPU_ONLY + { + auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + + // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op + if ((_Access_type != access_type_none) && _M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) + { + _Get_access_async(_M_buffer_descriptor._Get_view_key(), + _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), + _Get_synchronize_access_mode(_Access_type), + _PBuf)._Get(); + } + + details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Discards the current data underlying this view. This is an optimization + /// hint to the runtime used to avoid copying the current contents of the view to a target + /// accelerator_view that it is accessed on, and its use is recommended if the existing + /// content is not needed. This method is only available in a restrict(cpu) context and + /// cannot be used in a restrict(amp) context. + /// </summary> + void discard_data() const __CPU_ONLY + { + _M_buffer_descriptor._Get_buffer_ptr()->_Discard(_M_buffer_descriptor._Get_view_key()); + } + + /// <summary> + /// Returns the accelerator_view where the data source of the array_view is located. + /// If the array_view does not have a data source, this API throws a runtime_exception + /// </summary> + accelerator_view get_source_accelerator_view() const + { + if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) { + return _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(); + } + else { + throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG); + } + } + + __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view; + +private: + template <typename _T, int _R> + static array_view<_T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU + { + static_assert(sizeof(array_view<_T,_R>) == sizeof(_Array_view_base<_R,sizeof(_T)/sizeof(int)>), "ASSERT FAILURE: implementation relies on binary conversion between the two"); + return (*reinterpret_cast<const array_view<_T,_R>*>(&_Other)); + } + + void _Project0(int _I, array_view<_Value_type, _Rank-1> &_Projected_view) const __GPU + { + _Base::_Project0(_I, _Projected_view); + _Projected_view._Initialize(); + } + + array_view() __GPU {} + + array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + :_Base(_Other, _Section_origin, _Section_extent) + { + _Initialize(); + } + + array_view(_Buffer_descriptor& _Src_buffer, const Concurrency::extent<_Rank>& _Extent) __GPU + :_Base(_Src_buffer,_Extent) + { + _Initialize(); + } + + void _Initialize() __GPU + { + // Set the type access mode + _M_buffer_descriptor._M_type_access_mode = _Read_write_access; + } + + void _Initialize(size_t _Src_data_size, bool _Discard_data = false) __CPU_ONLY + { + // Ensure that the _Src_data_size is at least as big as the size + // of the array_view + if (_Src_data_size < this->extent.size()) { + throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG); + } + + _Initialize(); + + if (_Discard_data) { + discard_data(); + } + } + +}; // class array_view<T,R> + +// array_view<const T,R> +template <typename _Value_type, int _Rank> +class array_view<const _Value_type, _Rank> : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> +{ + _CPP_AMP_VERIFY_RANK(_Rank, array_view); + static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array views"); + + typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base; + + friend class details::_Const_array_view_projection_helper<_Value_type,_Rank>; + friend class details::_Const_array_view_projection_helper<_Value_type,_Rank+1>; + + friend class array_view<_Value_type, _Rank>; + friend class array_view<const _Value_type, _Rank>; + + friend class array_view<_Value_type, _Rank+1>; + friend class array_view<const _Value_type, _Rank+1>; + + friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<const _Value_type, _Rank>>(const array_view<const _Value_type, _Rank>& _Array) __GPU; + +public: + static const int rank = _Rank; + typedef typename const _Value_type value_type; + + /// <summary> + /// Destroys this array_view and reclaims resources. + /// </summary> + ~array_view() __GPU {} + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src array. The extent of the + /// array_view is that of the _Src array, and the origin of the array view is at zero. + /// </summary> + /// <param name="_Src"> + /// An array which contains the data that this array_view is bound to. + /// </param> + array_view(const array<_Value_type,_Rank>& _Src) __GPU + :_Base(_Get_buffer_descriptor(_Src), _Src.extent) + { + _Initialize(); + } + + /// <summary> + /// Copy constructor. Shallow copy. + /// </summary> + array_view(const array_view<_Value_type,_Rank>& _Src) __GPU + :_Base(_Src) + { + _Initialize(); + } + + /// <summary> + /// Copy constructor. Shallow copy. + /// </summary> + array_view(const array_view<const _Value_type,_Rank>& _Src) __GPU + :_Base(_Src) + { + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, const _Container& _Src) __CPU_ONLY + :_Base(_Src.data(),_Extent) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container; + //// The length of the array_view is the same as the length of the container + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> explicit array_view(const _Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size()))) + { + if (_Src.size() > INT_MAX) { + throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG); + } + static_assert( std::is_same<decltype(_Src.data()), const _Value_type*>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY + :_Base(_Src.data(),_Extent) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A pointer to the source data this array_view will bind to. If the number of elements pointed to + /// by _Src is less than the size of _Extent, undefined behavior results. + /// </param> + array_view(const Concurrency::extent<_Rank>& _Extent, const _Value_type * _Src) __GPU + :_Base(_Src,_Extent) + { + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_Extent"> + /// The extent of this array view. + /// </param> + /// <param name="_Src"> + /// A pointer to the source data this array_view will bind to. If the number of elements pointed to + /// by _Src is less than the size of _Extent, undefined behavior results. + /// </param> + array_view(const Concurrency::extent<_Rank>& _Extent, _In_ _Value_type * _Src) __GPU + :_Base(_Src,_Extent) + { + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(int _E0, const _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<1>(_E0)) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container; + //// The length of the array_view is the same as the length of the container + /// </summary> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Arr_type, int _Size> explicit array_view(const _In_ _Arr_type (&_Src) [_Size]) __GPU + :_Base(_Src, Concurrency::extent<1>(_Size)) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src)>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(int _E0, int _E1, const _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1)) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data contained in the _Src container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. + /// </param> + template <typename _Container> array_view(int _E0, int _E1, int _E2, const _Container& _Src) __CPU_ONLY + :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match"); + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(_Src.size()); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0, undefined behavior results. + /// </param> + array_view(int _E0, const _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<1>(_E0)) + { + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1, undefined behavior results. + /// </param> + array_view(int _E0, int _E1, const _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<2>(_E0,_E1)) + { + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1*_E2, undefined behavior results. + /// </param> + array_view(int _E0, int _E1, int _E2, const _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0, undefined behavior results. + /// </param> + array_view(int _E0, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<1>(_E0)) + { + static_assert(_Rank == 1, "rank must be 1"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1, undefined behavior results. + /// </param> + array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<2>(_E0,_E1)) + { + static_assert(_Rank == 2, "rank must be 2"); + _Initialize(); + } + + /// <summary> + /// Construct an array_view which is bound to the data pointed to by _Src. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array_view. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array_view. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array_view. + /// </param> + /// <param name="_Src"> + /// A container which contains the data that this array_view is bound to. If the number of elements pointed to + /// by _Src is less than _E0*_E1*_E2, undefined behavior results. + /// </param> + array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU + :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2)) + { + static_assert(_Rank == 3, "rank must be 3"); + _Initialize(); + } + + /// <summary> + /// Copy Assignment operator. Shallow copy. + /// </summary> + array_view& operator=(const array_view& _Other) __GPU + { + _Base::operator=(_Other); + return *this; + } + + /// <summary> + /// Copy Assignment operator. Shallow copy. + /// </summary> + array_view& operator=(const array_view<_Value_type, _Rank>& _Other) __GPU + { + _Base::operator=(_Other); + return *this; + } + + /// <summary> + /// Copies elements from this array_view to the destination array. + /// </summary> + void copy_to(array<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + copy(*this,_Dest); + } + + /// <summary> + /// Copies elements from this array_view to the destination array_view. + /// </summary> + void copy_to(const array_view<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + copy(*this,_Dest); + } + + /// <summary> + /// Projects the most-significant dimension of this array_view. If the array_view rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Const_result_type operator[] (int _I) const __GPU + { + return details::_Const_array_view_projection_helper<_Value_type,_Rank>::_Project0(this, _I); + } + + /// <summary> + /// Get a reference to the element indexed by _Index. Unlike the other indexing operators for accessing the + /// array_view on the CPU, this method does not implicitly synchronize this array_view's contents to the CPU. + /// After accessing the array_view on a remote location or performing a copy operation involving this array_view + /// users are responsible to explicitly synchronize the array_view to the CPU before calling this method. + /// Failure to do so results in undefined behavior. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// Reference to the element indexed by _Index + /// </returns> + value_type& get_ref(const index<_Rank>& _Index) const __GPU + { + void *_Ptr = _Access(_Index); + return *reinterpret_cast<value_type*>(_Ptr); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator[] (const index<_Rank>& _Index) const __GPU + { + return this->operator()(_Index); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator() (const index<_Rank>& _Index) const __GPU + { + void * _Ptr = _Access(_Read_access, _Index); + return *reinterpret_cast<value_type*>(_Ptr); + } + + /// <summary> + /// Projects the most-significant dimension of this array_view. If the array_view rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Const_result_type operator() (int _I) const __GPU + { + return details::_Const_array_view_projection_helper<_Value_type,_Rank>::_Project0(this, _I); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + value_type& operator() (int _I0, int _I1) const __GPU + { + static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>"); + return this->operator()(index<2>(_I0,_I1)); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + value_type& operator() (int _I0, int _I1, int _I2) const __GPU + { + static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>"); + return this->operator()(index<3>(_I0,_I1,_I2)); + } + + /// <summary> + /// Produces a subsection of the source array_view at the given origin and extent. + /// </summary> + /// <param name="_Section_origin"> + /// The origin of the section. + /// </param> + /// <param name="_Section_extent"> + /// The extent of the section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU + { + return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent)); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin of zero, with + /// an extent of _Ext. + /// </summary> + /// <param name="_Ext"> + /// The extent of this section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::extent<_Rank>& _Ext) const __GPU + { + return section(Concurrency::index<_Rank>(), _Ext); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin specified by an index, with + /// an extent of (this->exent - _Idx). + /// </summary> + /// <param name="_Idx"> + /// The index that specifies the origin of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(const Concurrency::index<_Rank>& _Idx) const __GPU + { + return section(_Idx, this->extent - _Idx); + } + + /// <summary> + /// Produces a one-dimensional subsection of the source array_view with origin specified by the index + /// components _I0, with extent _E0. + /// </summary> + /// <param name="_I0"> + /// The origin of this section. + /// </param> + /// <param name="_E0"> + /// The extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _E0) const __GPU + { + static_assert(_Rank == 1, "rank must be 1"); + return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0)); + } + + /// <summary> + /// Produces a two-dimensional subsection of the source array_view with origin specified by the index + /// components (_I0,_I1), with extent (_E0,_E1). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU + { + static_assert(_Rank == 2, "rank must be 2"); + return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1)); + } + + /// <summary> + /// Produces a three-dimensional subsection of the source array_view with origin specified by the index + /// components (_I0,_I1,_I2), with extent (_E0,_E1,_E2). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the origin of this section. + /// </param> + /// <param name="_I2"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The next-to-most-significant component of the extent of this section. + /// </param> + /// <param name="_E2"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU + { + static_assert(_Rank == 3, "rank must be 3"); + return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2)); + } + + /// <summary> + /// Produces a (possibly unsafe) reinterpretation of this array_view that is linear and with + /// a different element type. The size of _Value_type2 must evenly divide into the size of + /// this array_view. + /// </summary> + /// <returns> + /// A linear array_view with a reinterpreted element type. + /// </returns> + template <typename _Value_type2> array_view<const _Value_type2, _Rank> reinterpret_as() const __GPU + { + return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>()); + } + + /// <summary> + /// Produces an array_view of a different rank over this array_view's data. + /// </summary> + /// <param name="_View_extent"> + /// The reshaping extent. + /// </param> + /// <returns> + /// A reshaped array_view. + /// </returns> + template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU + { + return _Convert<_Value_type>(_View_as(_View_extent)); + } + + /// <summary> + /// Returns a pointer to the raw data of this array_view. + /// </summary> + const _Value_type* data() const __GPU + { + static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>"); + return &this->operator[](index<_Rank>()); + } + + /// <summary> + /// Informs the array_view that its bound memory has been modified outside + /// the array_view interface. This will render all cached information stale. + /// </summary> + void refresh() const __CPU_ONLY + { + _Buffer_ptr _PBuf; + _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get(); + } + + /// <summary> + /// Asynchronously synchronizes any modifications made to "this" array_view to the specified accelerator_view. + /// </summary> + /// <param name="_Accl_view"> + /// The target accelerator_view to synchronize to. + /// </param> + /// <returns> + /// A future upon which to wait for the operation to complete. + /// </returns> + concurrency::completion_future synchronize_to_async(const accelerator_view& _Accl_view) const __CPU_ONLY + { + auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + _Event _Ev; + + _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); + } + + /// <summary> + /// Asynchronously synchronizes any modifications made to "this" array_view to its source data. + /// </summary> + /// <returns> + /// A future upon which to wait for the operation to complete. + /// </returns> + concurrency::completion_future synchronize_async() const __CPU_ONLY + { + auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + _Event _Ev; + + // If the array_view corresponds to a ubiquitous buffer with no data source, + // then synchronize is a no-op + if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) { + _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf); + } + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); + } + + /// <summary> + /// Synchronizes any modifications made to "this" array_view to the specified accelerator_view. + /// </summary> + /// <param name="_Accl_view"> + /// The target accelerator_view to synchronize to. + /// </param> + void synchronize_to(const accelerator_view& _Accl_view) const __CPU_ONLY + { + auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + + _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Synchronizes any modifications made to "this" array_view to its source data. + /// </summary> + void synchronize() const __CPU_ONLY + { + auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor); + + _Buffer_ptr _PBuf; + + // If the array_view corresponds to a ubiquitous buffer with no data source, + // then synchronize is a no-op + if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) { + _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf)._Get(); + } + + details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Returns the accelerator_view where the data source of the array_view is located. + /// If the array_view does not have a data source, this API throws a runtime_exception + /// </summary> + accelerator_view get_source_accelerator_view() const + { + if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) { + return _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(); + } + else { + throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG); + } + } + + __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view; + +private: + template <typename _T, int _R> + static array_view<const _T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU + { + static_assert(sizeof(array_view<const _T,_R>) == sizeof(_Array_view_base<_R,sizeof(_T)/sizeof(int)>), "ASSERT FAILURE: implementation relies on binary conversion between the two"); + return (*reinterpret_cast<const array_view<const _T,_R>*>(&_Other)); + } + + void _Project0(int _I, array_view<const _Value_type, _Rank-1> &_Projected_view) const __GPU + { + _Base::_Project0(_I, _Projected_view); + _Projected_view._Initialize(); + } + + array_view() __GPU {} + + array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + : + _Base(_Other, _Section_origin, _Section_extent) + { + _Initialize(); + } + + void _Initialize() __GPU + { + // Set the type access mode + _M_buffer_descriptor._M_type_access_mode = _Read_access; + } + + void _Initialize(size_t _Src_data_size) __CPU_ONLY + { + // Ensure that the _Src_data_size is at least as big as the size + // of the array_view + if (_Src_data_size < this->extent.size()) { + throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG); + } + + _Initialize(); + } + +}; // class array_view<const T,R> + +// Forward declarations for copy functions +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest); +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest); +template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter); +template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter); +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest); +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest); +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest); +template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter); +template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter); + +namespace direct3d +{ + template<typename _Value_type, int _Rank> + array<_Value_type, _Rank> make_array(const Concurrency::extent<_Rank> &_Extent, const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_buffer) __CPU_ONLY; +} + +/// <summary> +/// An array is a multi-dimensional data aggregate on a accelerator_view. +/// </summary> +/// <param name="_Rank"> +/// The dimensionality of this array. +/// </param> +/// <param name="_Value_type"> +/// The type of the elements in the array. +/// </param> +template <typename _Value_type, int _Rank = 1> class array +{ + // internal storage abstraction + typedef details::_Buffer_descriptor _Buffer_descriptor; + typedef _Array_flatten_helper<_Rank, typename Concurrency::extent<_Rank>::value_type, typename Concurrency::index<_Rank>::value_type> _Flatten_helper; + + _CPP_AMP_VERIFY_RANK(_Rank, array); + static_assert(!std::is_const<_Value_type>::value, "array<const _Value_type> is not supported"); + static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array"); + + // Friends + template<typename _Value_type, int _Rank> + friend array<_Value_type,_Rank> direct3d::make_array(const Concurrency::extent<_Rank> &_Extent, const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_buffer) __CPU_ONLY; + friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __GPU; + friend _Ret_ _Ubiquitous_buffer* details::_Get_buffer<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __CPU_ONLY; + friend _Event details::_Get_access_async<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr) __CPU_ONLY; + + public: + static const int rank = _Rank; + typedef typename _Value_type value_type; + + /// <summary> + /// Construct an array from extents + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + explicit array(const Concurrency::extent<_Rank> & _Extent) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(details::_Select_default_accelerator().default_view, access_type_auto); + } + + /// <summary> + /// Construct array<T,1> with the extent _E0 + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + explicit array(int _E0) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int) is only permissible on array<T, 1>"); + _Initialize(details::_Select_default_accelerator().default_view, access_type_auto); + } + + /// <summary> + /// Construct an array<T,2> from two integer extents. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + explicit array(int _E0, int _E1) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int) is only permissible on array<T, 2>"); + _Initialize(details::_Select_default_accelerator().default_view, access_type_auto); + } + + /// <summary> + /// Construct an array<T,3> from three integer extents. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + explicit array(int _E0, int _E1, int _E2) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int) is only permissible on array<T, 3>"); + _Initialize(details::_Select_default_accelerator().default_view, access_type_auto); + } + + /// <summary> + /// Construct an array from extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + array(const Concurrency::extent<_Rank>& _Extent, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(_Av, _Cpu_access_type); + } + + /// <summary> + /// Construct array<T,1> with the extent _E0, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + array(int _E0, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, accelerator_view) is only permissible on array<T, 1>"); + _Initialize(_Av, _Cpu_access_type); + } + + /// <summary> + /// Construct an array<T,2> from two integer extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + array(int _E0, int _E1, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, accelerator_view) is only permissible on array<T, 2>"); + _Initialize(_Av, _Cpu_access_type); + } + + /// <summary> + /// Construct an array<T,3> from three integer extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, accelerator_view) is only permissible on array<T, 3>"); + _Initialize(_Av, _Cpu_access_type); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + array(const Concurrency::extent<_Rank>& _Extent, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(_Av, _Associated_Av); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + array(int _E0, accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, accelerator_view, accelerator_view) is only permissible on array<T, 1>"); + _Initialize(_Av, _Associated_Av); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + array(int _E0, int _E1, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, accelerator_view, accelerator_view) is only permissible on array<T, 2>"); + _Initialize(_Av, _Associated_Av); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, accelerator_view, accelerator_view) is only permissible on array<T, 3>"); + _Initialize(_Av, _Associated_Av); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from an iterator. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first) __CPU_ONLY + : _M_extent(_Extent) + { + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>"); + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from an iterator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>"); + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from an iterator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from an iterator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>"); + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from an iterator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from an iterator into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(_Extent) + { + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>"); + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from an iterator into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>"); + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from an iterator into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>"); + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct an array initialized from an iterator into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(_Extent) + { + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from an iterator into a container. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(_Extent) + { + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>"); + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from an iterator into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) + : _M_extent(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "array(int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>"); + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from an iterator into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "array(int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>"); + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_view, initialized from an iterator into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this array. + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this array. + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this array. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less + /// than this->extent.size(), undefined behavior results. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// An accelerator_view which specifies the preferred target location of the array. + /// </param> + template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "array(int, int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>"); + + _InputIterator _Src_last = _Src_first; + std::advance(_Src_last, this->extent.size()); + + _Initialize(_Av, _Associated_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct an array initialized from an array_view. + /// </summary> + /// <param name="_Src"> + /// An array_view to copy from. + /// </param> + explicit array(const array_view<const _Value_type,_Rank>& _Src) __CPU_ONLY + :_M_extent(_Src.extent) + { + _Initialize(details::_Select_default_accelerator().default_view, access_type_auto); + Concurrency::copy(_Src,*this); + } + + /// <summary> + /// Construct an array initialized from an array_view, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Src"> + /// An array_view to copy from. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this array resides. + /// </param> + /// <param name="_Cpu_access_type"> + /// The desired access_type for the array on the CPU. This + /// parameter has a default value of access_type_auto leaving the + /// CPU access_type determination to the runtime. The actual + /// CPU access_type for the array can be queried using the + /// get_cpu_access_type method. + /// </param> + array(const array_view<const _Value_type,_Rank>& _Src, accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY + :_M_extent(_Src.extent) + { + _Initialize(_Av, _Cpu_access_type); + Concurrency::copy(_Src,*this); + } + + /// <summary> + /// Construct a staging array between two associated accelerator_views, initialized from an array_view. + /// </summary> + /// <param name="_Src"> + /// An array_view to copy from. + /// </param> + /// <param name="_Av"> + /// An accelerator_view which specifies the location of the array. + /// </param> + /// <param name="_Associated_Av"> + /// The accelerator_view that is associated with _Av. + /// </param> + array(const array_view<const _Value_type,_Rank>& _Src, accelerator_view _Av, accelerator_view _Associated_Av) __CPU_ONLY + :_M_extent(_Src.extent) + { + _Initialize(_Av, _Associated_Av); + Concurrency::copy(_Src,*this); + } + + /// <summary> + /// Copy constructor. Deep copy. + /// </summary> + array(const array& _Other) __CPU_ONLY + : _M_extent(_Other._M_extent) + { + _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view); + Concurrency::copy(_Other, *this); + } + + /// <summary> + /// Move constructor. + /// </summary> + array(array && _Other) __CPU_ONLY + : _M_extent(_Other._M_extent), _M_multiplier(_Other._M_multiplier) + , _M_buffer_descriptor(_Other._M_buffer_descriptor) + { + // Register this + this->_Register_copy(_Other); + + // Release the _Other array + _Other._Unregister(); + _Other._M_buffer_descriptor._M_data_ptr = NULL; + _Other._M_buffer_descriptor._Set_buffer_ptr(NULL); + } + + /// <summary> + /// Copy Assignment operator. Deep copy. + /// </summary> + array & operator= (const array & _Other) __CPU_ONLY + { + if (this != &_Other) + { + // First unregister myself from the current buffer + _Unregister(); + + _M_extent = _Other._M_extent; + _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view); + Concurrency::copy(_Other, *this); + } + return *this; + } + + /// <summary> + /// Move Assignment operator. + /// </summary> + array & operator= (array && _Other) __CPU_ONLY + { + if (this != &_Other) + { + // First unregister myself from the current buffer + _Unregister(); + + _M_extent = _Other._M_extent; + _M_multiplier = _Other._M_multiplier; + _M_buffer_descriptor = _Other._M_buffer_descriptor; + this->_Register_copy(_Other); + + // Release the _Other array + _Other._Unregister(); + _Other._M_buffer_descriptor._M_data_ptr = NULL; + _Other._M_buffer_descriptor._Set_buffer_ptr(NULL); + } + return *this; + } + + /// <summary> + /// Assignment operator from an array_view + /// </summary> + array& operator=(const array_view<const _Value_type,_Rank>& _Src) __CPU_ONLY + { + Concurrency::copy(_Src,*this); + return *this; + } + + /// <summary> + /// Copies elements from this array to the destination array. + /// </summary> + void copy_to(array<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + Concurrency::copy(*this, _Dest); + } + + /// <summary> + /// Copies elements from this array to the destination array_view. + /// </summary> + void copy_to(const array_view<_Value_type,_Rank>& _Dest) const __CPU_ONLY + { + Concurrency::copy(*this,_Dest); + } + + /// <summary> + /// Returns the extent that defines the shape of this array. + /// </summary> + __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent; + Concurrency::extent<_Rank> get_extent() const __GPU + { + return _M_extent; + } + + /// <summary> + /// Returns the accelerator_view where this array is located. + /// </summary> + __declspec(property(get=get_accelerator_view)) Concurrency::accelerator_view accelerator_view; + Concurrency::accelerator_view get_accelerator_view() const __CPU_ONLY + { + return _Get_buffer()->_Get_master_buffer()->_Get_access_on_accelerator_view(); + } + + /// <summary> + /// Returns the accelerator_view that is the preferred target where this array can be copied. + /// </summary> + __declspec(property(get=get_associated_accelerator_view)) Concurrency::accelerator_view associated_accelerator_view; + Concurrency::accelerator_view get_associated_accelerator_view() const __CPU_ONLY + { + return _Get_buffer()->_Get_master_buffer()->_Get_accelerator_view(); + } + + /// <summary> + /// Returns the CPU access_type allowed for this array. + /// </summary> + __declspec(property(get=get_cpu_access_type)) access_type cpu_access_type; + access_type get_cpu_access_type() const __CPU_ONLY + { + return _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_type(); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator[] (const index<_Rank>& _Index) __GPU + { + // Refresh the data ptr if needed + _Refresh_data_ptr(_Read_write_access); + + _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr); + return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)]; + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + const value_type& operator[] (const index<_Rank>& _Index) const __GPU + { + // Refresh the data ptr if needed +#pragma warning( push ) +#pragma warning( disable : 4880 ) + // Casting away constness in amp restricted scope might result in + // undefined behavior, therefore, the compiler will report a level 1 warning + // for it. But the following const_cast is harmless thus we are suppressing + // this warning just for this line. + const_cast<array*>(this)->_Refresh_data_ptr(_Read_access); +#pragma warning( pop ) + + _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr); + return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)]; + } + + /// <summary> + /// Projects the most-significant dimension of this array. If the array rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Result_type operator[](int _I) __GPU + { + return details::_Array_projection_helper<_Value_type,_Rank>::_Project0(this,_I); + } + + /// <summary> + /// Projects the most-significant dimension of this array. If the array rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Const_result_type operator[](int _I) const __GPU + { + return details::_Const_array_projection_helper<_Value_type,_Rank>::_Project0(this,_I); + } + + /// <summary> + /// Get the element value indexed by _I + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I + /// </returns> + value_type& operator() (const index<_Rank>& _Index) __GPU + { + return this->operator[](_Index); + } + + /// <summary> + /// Get the element value indexed by _Index + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index + /// </returns> + const value_type& operator() (const index<_Rank>& _Index) const __GPU + { + return this->operator[](_Index); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + value_type& operator() (int _I0, int _I1) __GPU + { + static_assert(_Rank == 2, "value_type& array::operator()(int, int) is only permissible on array<T, 2>"); + return this->operator[](index<2>(_I0, _I1)); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + const value_type& operator() (int _I0, int _I1) const __GPU + { + static_assert(_Rank == 2, "const value_type& array::operator()(int, int) is only permissible on array<T, 2>"); + return this->operator[](index<2>(_I0, _I1)); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + value_type& operator() (int _I0, int _I1, int _I2) __GPU + { + static_assert(_Rank == 3, "value_type& array::operator()(int, int, int) is only permissible on array<T, 3>"); + return this->operator[](index<3>(_I0, _I1, _I2)); + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + const value_type& operator() (int _I0, int _I1, int _I2) const __GPU + { + static_assert(_Rank == 3, "const value_type& array::operator()(int, int, int) const is only permissible on array<T, 3>"); + return this->operator[](index<3>(_I0, _I1, _I2)); + } + + /// <summary> + /// Projects the most-significant dimension of this array. If the array rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Result_type operator()(int _I) __GPU + { + return details::_Array_projection_helper<_Value_type,_Rank>::_Project0(this,_I); + } + + /// <summary> + /// Projects the most-significant dimension of this array. If the array rank is 1, this + /// produces a single element; otherwise it produces an array_view with one fewer dimensions. + /// </summary> + /// <param name="_I"> + /// The most-significant index component + /// </param> + /// <returns> + /// The element at index component _I, or an array_view projected on the most-significant dimension. + /// </returns> + typename details::_Projection_result_type<_Value_type,_Rank>::_Const_result_type operator()(int _I) const __GPU + { + return details::_Const_array_projection_helper<_Value_type,_Rank>::_Project0(this,_I); + } + + /// <summary> + /// Produces a subsection of the source array at the given origin and extent. + /// </summary> + /// <param name="_Section_origin"> + /// The origin of the section. + /// </param> + /// <param name="_Section_extent"> + /// The extent of the section + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<_Value_type,_Rank> section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU + { + array_view<_Value_type,_Rank> _T1(*this); + return _T1.section(_Section_origin, _Section_extent); + } + + /// <summary> + /// Produces a subsection of the source array at the given origin and extent. + /// </summary> + /// <param name="_Section_origin"> + /// The origin of the section. + /// </param> + /// <param name="_Section_extent"> + /// The extent of the section + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<const _Value_type,_Rank> section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU + { + array_view<const _Value_type,_Rank> _T1(*this); + return _T1.section(_Section_origin, _Section_extent); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin of zero, with + /// an extent of _Ext. + /// </summary> + /// <param name="_Ext"> + /// The extent of this section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view<_Value_type,_Rank> section(const Concurrency::extent<_Rank>& _Ext) __GPU + { + return section(Concurrency::index<_Rank>(), _Ext); + } + + /// <summary> + /// Produces a subsection of the source array_view with origin of zero, with + /// an extent of _Ext. + /// </summary> + /// <param name="_Ext"> + /// The extent of this section + /// </param> + /// <returns> + /// A subsection of the array_view. + /// </returns> + array_view<const _Value_type,_Rank> section(const Concurrency::extent<_Rank>& _Ext) const __GPU + { + return section(Concurrency::index<_Rank>(), _Ext); + } + + /// <summary> + /// Produces a subsection of the source array with origin specified by an index, with + /// an extent of (this->exent - _Idx). + /// </summary> + /// <param name="_Idx"> + /// The index that specifies the origin of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<_Value_type,_Rank> section(const index<_Rank>& _Idx) __GPU + { + array_view<_Value_type,_Rank> _T1(*this); + return _T1.section(_Idx); + } + + /// <summary> + /// Produces a subsection of the source array with origin specified by an index, with + /// an extent of (this->exent - _Idx). + /// </summary> + /// <param name="_Idx"> + /// The index that specifies the origin of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<const _Value_type,_Rank> section(const index<_Rank>& _Idx) const __GPU + { + array_view<const _Value_type,_Rank> _T1(*this); + return _T1.section(_Idx); + } + + /// <summary> + /// Produces a one-dimensional subsection of the source array with origin specified by the index + /// components _I0, with extent _E0. + /// </summary> + /// <param name="_I0"> + /// The origin of this section. + /// </param> + /// <param name="_E0"> + /// The extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<_Value_type,1> section(int _I0, int _E0) __GPU + { + array_view<_Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_E0); + } + + /// <summary> + /// Produces a one-dimensional subsection of the source array with origin specified by the index + /// components _I0, with extent _E0. + /// </summary> + /// <param name="_I0"> + /// The origin of this section. + /// </param> + /// <param name="_E0"> + /// The extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<const _Value_type,1> section(int _I0, int _E0) const __GPU + { + array_view<const _Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_E0); + } + + /// <summary> + /// Produces a two-dimensional subsection of the source array with origin specified by the index + /// components (_I0,_I1), with extent (_E0,_E1). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<_Value_type,2> section(int _I0, int _I1, int _E0, int _E1) __GPU + { + array_view<_Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_I1,_E0,_E1); + } + + /// <summary> + /// Produces a two-dimensional subsection of the source array with origin specified by the index + /// components (_I0,_I1), with extent (_E0,_E1). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<const _Value_type,2> section(int _I0, int _I1, int _E0, int _E1) const __GPU + { + array_view<const _Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_I1,_E0,_E1); + } + + /// <summary> + /// Produces a three-dimensional subsection of the source array with origin specified by the index + /// components (_I0,_I1,_I2), with extent (_E0,_E1,_E2). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the origin of this section. + /// </param> + /// <param name="_I2"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The next-to-most-significant component of the extent of this section. + /// </param> + /// <param name="_E2"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<_Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) __GPU + { + array_view<_Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2); + } + + /// <summary> + /// Produces a three-dimensional subsection of the source array with origin specified by the index + /// components (_I0,_I1,_I2), with extent (_E0,_E1,_E2). + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the origin of this section. + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the origin of this section. + /// </param> + /// <param name="_I2"> + /// The least-significant component of the origin of this section. + /// </param> + /// <param name="_E0"> + /// The most-significant component of the extent of this section. + /// </param> + /// <param name="_E1"> + /// The next-to-most-significant component of the extent of this section. + /// </param> + /// <param name="_E2"> + /// The least-significant component of the extent of this section. + /// </param> + /// <returns> + /// A subsection of the array. + /// </returns> + array_view<const _Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU + { + array_view<const _Value_type,_Rank> _T1(*this); + return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2); + } + + /// <summary> + /// Produces a (possibly unsafe) reinterpretation of this array that is linear and with + /// a different element type. + /// </summary> + /// <returns> + /// A linear array_view with a reinterpreted element type. + /// </returns> + template <typename _Value_type2> array_view<_Value_type2,1> reinterpret_as() __GPU + { + return array_view<_Value_type,1>(_M_buffer_descriptor, Concurrency::extent<1>(extent.size())).template reinterpret_as<_Value_type2>(); + } + + /// <summary> + /// Produces a (possibly unsafe) reinterpretation of this array that is linear and with + /// a different element type. + /// </summary> + /// <returns> + /// A linear array_view with a reinterpreted element type. + /// </returns> + template <typename _Value_type2> array_view<const _Value_type2,1> reinterpret_as() const __GPU + { +#pragma warning( push ) +#pragma warning( disable : 4880 ) + // Casting away constness in amp restricted scope might result in + // undefined behavior, therefore, the compiler will report a level 1 warning + // for it. But the following const_cast is harmless thus we are suppressing + // this warning just for this line. + return const_cast<array*>(this)->reinterpret_as<_Value_type2>(); +#pragma warning( pop ) + } + + /// <summary> + /// Produces an array_view of a different rank over this array's data. + /// </summary> + /// <param name="_View_extent"> + /// The reshaping extent. + /// </param> + /// <returns> + /// A reshaped array_view. + /// </returns> + template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) __GPU + { + return array_view<_Value_type,_New_rank>(_M_buffer_descriptor, _View_extent); + } + + /// <summary> + /// Produces an array_view of a different rank over this array's data. + /// </summary> + /// <param name="_View_extent"> + /// The reshaping extent. + /// </param> + /// <returns> + /// A reshaped array_view. + /// </returns> + template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU + { +#pragma warning( push ) +#pragma warning( disable : 4880 ) + // Casting away constness in amp restricted scope might result in + // undefined behavior, therefore, the compiler will report a level 1 warning + // for it. But the following const_cast is harmless thus we are suppressing + // this warning just for this line. + return const_cast<array*>(this)->view_as<_New_rank>(_View_extent); +#pragma warning( pop ) + } + + /// <summary> + /// Implicitly converts this array into a vector by copying. + /// </summary> + operator std::vector<_Value_type>() const __CPU_ONLY + { + std::vector<_Value_type> _return_vector(extent.size()); + Concurrency::copy(*this, _return_vector.begin()); + + return _return_vector; + } + + /// <summary> + /// Returns a pointer to the raw data of this array. + /// </summary> + _Ret_ _Value_type* data() __GPU + { + _Refresh_data_ptr(_Read_write_access, false /* _Exception */); + return reinterpret_cast<_Value_type*>(_M_buffer_descriptor._M_data_ptr); + } + + /// <summary> + /// Returns a pointer to the raw data of this array. + /// </summary> + const _Value_type* data() const __GPU + { +#pragma warning( push ) +#pragma warning( disable : 4880 ) + // Casting away constness in amp restricted scope might result in + // undefined behavior, therefore, the compiler will report a level 1 warning + // for it. But the following const_cast is harmless thus we are suppressing + // this warning just for this line. + const_cast<array*>(this)->_Refresh_data_ptr(_Read_access, false /* _Exception */); +#pragma warning( pop ) + return reinterpret_cast<const _Value_type*>(_M_buffer_descriptor._M_data_ptr); + } + + /// <summary> + /// Destroys this array and reclaims resources. + /// </summary> + ~array() __CPU_ONLY + { + bool _Can_throw = (std::current_exception() == nullptr); + + // Destructor should not throw if we are already processing + // an exception and another exception will result in termination + try { + _Unregister(); + } + catch(...) + { + if (_Can_throw) { + throw; + } + } + } + +private: + + // No default constructor + array() __CPU_ONLY; + + // Private constructor used by direct3d::make_array + array(const Concurrency::extent<_Rank>& _Extent, _Buffer_descriptor _Buffer_descriptor) + : _M_extent(_Extent), _M_buffer_descriptor(_Buffer_descriptor) + { + _Initialize(); + + // Register this + this->_Register(); + } + + // Initialize + unsigned int _Initialize() __CPU_ONLY + { + details::_Is_valid_extent(_M_extent); + + // Arrays always have a type access mode of '_Is_array_mode' + // This is the mechanism for differentiating between arrays and array_views by the runtime + _M_buffer_descriptor._M_type_access_mode = _Is_array_mode; + unsigned int totalExtent = _M_extent[_Rank-1]; + details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(totalExtent, _M_multiplier, _M_extent); + + return totalExtent; + } + + // Initialize and allocate on specified accelerator_view + void _Initialize(Concurrency::accelerator_view _Av, access_type _Cpu_access_type) __CPU_ONLY + { + unsigned int totalExtent = _Initialize(); + // release the existing buffer if any before allocation new one + _M_buffer_descriptor._Set_buffer_ptr(NULL); + + _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, _Cpu_access_type); + + _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf)); + _Register(); + } + + // Initialize and allocate on specified accelerator_view and copy specified data + template <typename _InputIterator> + void _Initialize(Concurrency::accelerator_view _Av, _InputIterator _Src_first, _InputIterator _Src_last, access_type _Cpu_access_type) __CPU_ONLY + { + _Initialize(_Av, _Cpu_access_type); + copy(_Src_first, _Src_last, *this); + } + + // Initialize and allocate on specified accelerator_views + void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY + { + unsigned int totalExtent = _Initialize(); + + // Staging arrays can only be created if the accelerator_view is on the cpu_accelerator + _Buffer_ptr _PBuf = NULL; + + // release the existing buffer if any before allocation new one + _M_buffer_descriptor._Set_buffer_ptr(NULL); + + if (_Is_cpu_accelerator(_Av.accelerator)) + { + // If the accelerator _Associated_Av supports zero-copy and the default cpu access type + // for the accelerator is access_type_read_write, create a zero-copy buffer instead of a + // staging buffer + if (_Associated_Av.accelerator.supports_cpu_shared_memory && (_Get_recommended_buffer_host_access_mode(_Associated_Av) == _Read_write_access)) { + _PBuf = _Buffer::_Create_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_read_write); + } + else { + _PBuf = _Buffer::_Create_stage_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type)); + } + + _PBuf->_Map_buffer(_Read_write_access, true /* _Wait */); + } + else + { + _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_auto); + } + + _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf)); + _Register(); + } + + // Initialize and allocate on specified accelerator_views + template <typename _InputIterator> + void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY + { + _Initialize(_Av, _Associated_Av); + copy(_Src_first, _Src_last, *this); + } + + void _Register() __CPU_ONLY + { + Concurrency::accelerator_view cpuAv = _Is_cpu_accelerator(this->accelerator_view.accelerator) ? + this->accelerator_view : accelerator(accelerator::cpu_accelerator).default_view; + _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(), cpuAv, _Create_buffer_view_shape()); + + _M_buffer_descriptor._Get_buffer_ptr()->_Discard(_M_buffer_descriptor._Get_view_key()); + + // If the array is on the CPU accelerator then we will ensure that the descriptor + // indicates CPU access + if (_Is_cpu_accelerator(this->accelerator_view.accelerator)) + { + _Buffer_ptr _PBuf = NULL; + this->_Get_access_async(_Read_write_access, _PBuf, false)._Get(); + } + } + + void _Register_copy(const array &_Other) __CPU_ONLY + { + _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key()); + } + + void _Unregister() __CPU_ONLY + { + // No need to unregister if the array was moved causing the buffer ptr to be set to NULL + if (_M_buffer_descriptor._Get_buffer_ptr() != NULL) { + _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key()); + } + } + + _Ret_ _Ubiquitous_buffer* _Get_buffer() __CPU_ONLY const + { + return _M_buffer_descriptor._Get_buffer_ptr(); + } + + _Event _Get_access_async(_Access_mode _Mode, _Buffer_ptr &_Buf_ptr, bool _Zero_copy_cpu_access = false) __CPU_ONLY const + { + _ASSERTE(!_Zero_copy_cpu_access || (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access)); + + _Buffer_ptr _PBuf; + Concurrency::accelerator_view _Access_av = _Zero_copy_cpu_access ? accelerator(accelerator::cpu_accelerator).default_view : this->accelerator_view; + _Event _Ev = details::_Get_access_async(_M_buffer_descriptor._Get_view_key(), + _Access_av, + _Mode, _PBuf); + _Buf_ptr = _PBuf; + + if (_Is_cpu_accelerator(_Access_av.accelerator)) { + _Ev = _Ev._Add_continuation(std::function<_Event()>([_PBuf, this]() mutable -> _Event { + const_cast<array*>(this)->_M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr(); + return _Event(); + })); + } + + return _Ev; + } + + _Ret_ _View_shape* _Create_buffer_view_shape() const + { + _ASSERTE(_Get_buffer()->_Get_master_buffer_elem_size() == sizeof(_Value_type)); + + unsigned int _ZeroOffset[_Rank] = {0}; + unsigned int _View_extent[_Rank]; + for(int i=0; i<_Rank; ++i) + { + _View_extent[i] = static_cast<unsigned int>(this->_M_extent[i]); + } + return _View_shape::_Create_view_shape(static_cast<unsigned int>(_Rank), 0, &_View_extent[0], &_ZeroOffset[0], &_View_extent[0]); + } + + bool _Has_cpu_access() const __CPU_ONLY + { + return (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access); + } + + void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception = true) __CPU_ONLY + { + _ASSERTE(_Is_valid_access_mode(_Requested_mode)); + + // For an array that has CPU access, the maximum CPU access allowed is that allowed by + // the underlying _Buffer allocation + _Requested_mode = static_cast<_Access_mode>(_Requested_mode & _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode()); + + // Refresh the data ptr if we do not have requested access + if ((_Requested_mode == _No_access) || ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode)) + { + if (_Has_cpu_access() && (_Requested_mode != _No_access)) + { + auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor); + _Buffer_ptr _PBuf; + bool _Zero_copy_cpu_access = !_Is_cpu_accelerator(this->accelerator_view.accelerator); + this->_Get_access_async(_Requested_mode, _PBuf, _Zero_copy_cpu_access)._Get(); + details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + else + { + if (_Exception) + { + if (!_Has_cpu_access()) { + throw runtime_exception("The array is not accessible on CPU.", E_FAIL); + } + else { + throw runtime_exception("The array is not accessible for reading on CPU.", E_FAIL); + } + } + } + } + } + + void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception = true) __GPU_ONLY + { + UNREFERENCED_PARAMETER(_Requested_mode); + UNREFERENCED_PARAMETER(_Exception); + } + +private: + // Data members + + Concurrency::extent<_Rank> _M_extent; + + // Descriptor of the buffer underlying the array + _Buffer_descriptor _M_buffer_descriptor; + + // The vector used for index calculation. + Concurrency::extent<_Rank> _M_multiplier; +}; + +namespace details +{ +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest) +{ + if (_Src.extent.size() > _Dest.extent.size()) + { + throw runtime_exception("Invalid _Src argument. _Src size exceeds total size of the _Dest.", E_INVALIDARG); + } + + // We can obliterate the exisiting content of dest if it is about to be totally overwritten + _Access_mode _Dest_access_mode = (_Src.extent.size() == _Dest.extent.size()) ? _Write_access : _Read_write_access; + + _Buffer_ptr _PBufSrc, _PBufDest; + _Event _Ev = _Get_access_async(_Src, _Read_access, _PBufSrc); + _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Dest_access_mode, _PBufDest)); + size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PBufSrc->_Get_elem_size(); + return _Ev._Add_continuation(std::function<_Event()>([_PBufSrc, _PBufDest, _NumElemsToCopy]() mutable -> _Event { + return details::_Copy_impl(_PBufSrc, 0, _PBufDest, 0, _NumElemsToCopy); + })); +} + +template <typename InputIterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest) +{ + size_t _NumElemsToCopy = std::distance(_SrcFirst, _SrcLast); + // We can obliterate the exisiting content of dest if it is about to be totally overwritten + _Access_mode _Dest_access_mode = (_NumElemsToCopy == _Dest.extent.size()) ? _Write_access : _Read_write_access; + _Buffer_ptr _PDestBuf; + _Event _Ev = _Get_access_async(_Dest, _Dest_access_mode, _PDestBuf); + + return _Ev._Add_continuation(std::function<_Event()>([_SrcFirst, _SrcLast, _PDestBuf, _NumElemsToCopy]() mutable -> _Event { + return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _NumElemsToCopy, _PDestBuf, 0); + })); +} + +template <typename OutputIterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + _Buffer_ptr _PSrcBuf; + _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf); + size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size(); + return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _NumElemsToCopy, _DestIter]() mutable -> _Event { + return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, 0, _NumElemsToCopy, _DestIter); + })); +} + +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src); + const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest); + if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) { + throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG); + } + + _Buffer_ptr _PSrcBuf, _PDestBuf; + _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf); + + // The source accelerator_view is driven by array's master location, + // therefore we can pass nullptr to avoid unnecessary computation + auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc); + + _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf)); + _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc); + _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc); + return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event { + return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape); + })); +} + +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest) +{ + const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src); + const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest); + if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) { + throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG); + } + + auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc); + + _Buffer_ptr _PSrcBuf, _PDestBuf; + _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf); + _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Write_access, _PDestBuf)); + _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc); + _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc); + return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event { + return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape); + })); +} + +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src); + const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest); + _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc); + _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc); + if ((_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) && _PSrcShape->_Overlaps(_PDestShape)) { + throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG); + } + + auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc); + + _Buffer_ptr _PSrcBuf, _PDestBuf; + _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf); + _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf)); + return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event { + return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape); + })); +} + +template <typename InputIterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest) +{ + static_assert(!std::is_const<_Value_type>::value, "Cannot copy to array_view<const _Value_type, _Rank>."); + + size_t _Src_size = std::distance(_SrcFirst, _SrcLast); + + // Source cannot be greater than destination + if (_Src_size > _Dest.extent.size()) + { + throw runtime_exception("Number of elements in range between [_SrcFirst, _SrcLast) exceeds total size of the _Dest.", E_INVALIDARG); + } + +#pragma warning( push ) +#pragma warning( disable : 4127 ) // Disable warning about constant conditional expression + // Higher ranks need to have as many elements as in _Dest array_view + if ((_Rank > 1) && (_Src_size != _Dest.extent.size())) + { + throw runtime_exception("For _Rank > 1 the number of elements in range between [_SrcFirst, _SrcLast) has to be equal to total size of the _Dest.", E_INVALIDARG); + } +#pragma warning( pop ) + + // We can obliterate the exisiting content of dest if it is about to be totally overwritten + _Access_mode _Dest_access_mode = (_Src_size == _Dest.extent.size()) ? _Write_access : _Read_write_access; + + // Get read-write access for array_view on cpu_accelerator and take underlying pointer to data + const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest); + + auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc); + + _Buffer_ptr _PDestBuf; + _Event _Ev = _Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Dest_access_mode, _PDestBuf); + + _View_shape_ptr _Dst_shape = _Get_buffer_view_shape(_DestBufDesc); + + // If the _Dst shape is linear then perform a linear copy + unsigned int _Dst_linear_offset, _Dst_linear_size; + if (_Dst_shape->_Is_view_linear(_Dst_linear_offset, _Dst_linear_size)) + { + _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _SrcLast, _Src_size, _Dst_linear_offset]() mutable -> _Event { + return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _Src_size, _PDestBuf, _Dst_linear_offset); + })); + } + else + { + _View_shape_ptr _Reinterpreted_dst_shape = _Create_reinterpreted_shape(_Dst_shape, _PDestBuf->_Get_elem_size(), sizeof(_Value_type)); + + // Source has as many elements as in destination, reshape source to match destination shape + std::vector<unsigned int> _Src_offset(_Reinterpreted_dst_shape->_Get_rank(), 0); + _View_shape_ptr _Src_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_dst_shape->_Get_rank(), 0 /* linear offset*/, + _Reinterpreted_dst_shape->_Get_view_extent(), _Src_offset.data(), + _Reinterpreted_dst_shape->_Get_view_extent()); + + _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _Src_shape, _Dst_shape]() mutable -> _Event { + return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _Src_shape, _PDestBuf, _Dst_shape); + })); + } + + return _Ev; +} + +template <typename OutputIterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + // Caller is responsible for passing valid _DestIter + + // Get read access for array_view on cpu_accelerator and take underlying pointer to data + const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src); + + auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, nullptr); + + _Buffer_ptr _PSrcBuf; + _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf); + + // Get source shape + _View_shape_ptr _Src_shape = _Get_buffer_view_shape(_SrcBufDesc); + + // If the _Src_shape is linear then perform a linear copy + unsigned int _Src_linear_offset, _Src_linear_size; + if (_Src_shape->_Is_view_linear(_Src_linear_offset, _Src_linear_size)) + { + _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter]() mutable -> _Event { + return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter); + })); + } + else + { + _View_shape_ptr _Reinterpreted_src_shape = _Create_reinterpreted_shape(_Src_shape, _PSrcBuf->_Get_elem_size(), sizeof(_Value_type)); + + // Valid destination should have space for as many elements as in source array_view, reshape to match source view shape + std::vector<unsigned int> _Dst_offset(_Reinterpreted_src_shape->_Get_rank(), 0); + _View_shape_ptr _Dst_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_src_shape->_Get_rank(), 0 /* linear offset*/, + _Reinterpreted_src_shape->_Get_view_extent(), _Dst_offset.data(), + _Reinterpreted_src_shape->_Get_view_extent()); + + _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_shape, _DestIter, _Dst_shape]() mutable -> _Event { + return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_shape, _DestIter, _Dst_shape); + })); + } + + return _Ev; +} + +} + +/// <summary> +/// Asynchronously copies the contents of the source array into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + auto _Ev = _Copy_async_impl(_Src, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the source array into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the elements in the range [_SrcFirst, _SrcLast) into the destination array. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container. +/// </param> +/// <param name="_SrcLast"> +/// An ending iterator into the source container. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast)); + + _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the elements in the range [_SrcFirst, _SrcLast) into the destination array. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container. +/// </param> +/// <param name="_SrcLast"> +/// An ending iterator into the source container. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast)); + + _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the elements beginning at _SrcFirst into the destination array. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less +/// than _Dest.extent.size(), undefined behavior results. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest) +{ + InputIterator _SrcLast = _SrcFirst; + std::advance(_SrcLast, _Dest.extent.size()); + return copy_async(_SrcFirst, _SrcLast, _Dest); +} + +/// <summary> +/// Copies the elements beginning at _SrcFirst into the destination array. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less +/// than _Dest.extent.size(), undefined behavior results. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest) +{ + InputIterator _SrcLast = _SrcFirst; + std::advance(_SrcLast, _Dest.extent.size()); + copy(_SrcFirst, _SrcLast, _Dest); +} + +/// <summary> +/// Asynchronously copies the contents of the array into the destination beginning at _DestIter. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_DestIter"> +/// An output iterator to the beginning position at destination. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator); + + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + nullptr, + sizeof(_Value_type) * _Src.extent.size()); + _Event _Ev = _Copy_async_impl(_Src, _DestIter); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the array into the destination beginning at _DestIter. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_DestIter"> +/// An output iterator to the beginning position at destination. +/// </param> +template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator); + + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + nullptr, + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _DestIter)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the contents of the source array into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Event _Ev = _Copy_async_impl(_Src, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the source array into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the contents of the source array_view into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Event _Ev = _Copy_async_impl(_Src, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the source array_view into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the contents of the source array_view into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest) +{ + return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest); +} + +/// <summary> +/// Copies the contents of the source array_view into the destination array. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest) +{ + copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest); +} + +/// <summary> +/// Asynchronously copies the contents of the source array_view into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Event _Ev = _Copy_async_impl(_Src, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the source array_view into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies the contents of the source array_view into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest); +} + +/// <summary> +/// Copies the contents of the source array_view into the destination array_view. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest) +{ + copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest); +} + +/// <summary> +/// Asynchronously copies the elements in the range [_SrcFirst, _SrcLast) into the destination array_view. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container. +/// </param> +/// <param name="_SrcLast"> +/// An ending iterator into the source container. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest) +{ + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast)); + + _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies the elements beginning at _SrcFirst into the destination array_view. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less +/// than _Dest.extent.size(), undefined behavior results. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest) +{ + InputIterator _SrcLast = _SrcFirst; + std::advance(_SrcLast, _Dest.extent.size()); + return copy_async(_SrcFirst, _SrcLast, _Dest); +} + +/// <summary> +/// Copies the elements in the range [_SrcFirst, _SrcLast) into the destination array_view. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container. +/// </param> +/// <param name="_SrcLast"> +/// An ending iterator into the source container. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest) +{ + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + details::_Get_buffer_descriptor(_Dest), + sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast)); + + _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies the contents of an STL container into the destination array_view. +/// </summary> +/// <param name="_SrcFirst"> +/// A beginning iterator into the source container; if the number of available container elements starting at this iterator position is less +/// than _Dest.extent.size(), undefined behavior results. +/// </param> +/// <param name="_Dest"> +/// The destination array_view. +/// </param> +template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest) +{ + InputIterator _SrcLast = _SrcFirst; + std::advance(_SrcLast, _Dest.extent.size()); + copy(_SrcFirst, _SrcLast, _Dest); +} + +/// <summary> +/// Asynchronously copies the contents of the array_view into the destination beginning at _DestIter. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_DestIter"> +/// An output iterator to the beginning position at destination. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator); + + // Caller is responsible for passing valid _DestIter + auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(details::_Get_buffer_descriptor(_Src), + nullptr, + sizeof(_Value_type) * _Src.extent.size()); + + _Event _Ev = _Copy_async_impl(_Src, _DestIter); + + return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies the contents of the array_view into the destination beginning at _DestIter. +/// </summary> +/// <param name="_Src"> +/// The source array_view. +/// </param> +/// <param name="_DestIter"> +/// An output iterator to the beginning position at destination. +/// </param> +template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter) +{ + _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator); + + auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(details::_Get_buffer_descriptor(_Src), + nullptr, + sizeof(_Value_type) * _Src.extent.size()); + + _Copy_async_impl(_Src, _DestIter)._Get(); + + details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +// Namespace for Direct3D specific functionality +namespace direct3d +{ + /// <summary> + /// Get the D3D buffer interface underlying an array. + /// </summary> + /// <param name="_Rank"> + /// The rank of the array to get underlying D3D buffer of. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements in the array to get underlying D3D buffer of. + /// </param> + /// <param name="_Array"> + /// A array on a D3D accelerator_view for which the underlying D3D buffer interface is returned. + /// </param> + /// <returns> + /// The IUnknown interface pointer corresponding to the D3D buffer underlying the array. + /// </returns> + template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_buffer(const array<_Value_type, _Rank> &_Array) __CPU_ONLY + { + _Buffer_ptr _PBuf; + _Get_access_async(_Array, _Read_write_access, _PBuf)._Get(); + return details::_D3D_interop::_Get_D3D_buffer(_PBuf); + } + + /// <summary> + /// Create an array from a D3D buffer interface pointer. + /// </summary> + /// <param name="_Rank"> + /// The rank of the array to be created from the D3D buffer. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements of the array to be created from the D3D buffer. + /// </param> + /// <param name="_Extent"> + /// An extent that describes the shape of the array aggregate. + /// </param> + /// <param name="_Av"> + /// A D3D accelerator_view on which the array is to be created. + /// </param> + /// <param name="_D3D_buffer"> + /// IUnknown interface pointer of the D3D buffer to create the array from. + /// </param> + /// <returns> + /// A array created using the provided D3D buffer. + /// </returns> + template<typename _Value_type, int _Rank> array<_Value_type, _Rank> make_array(const Concurrency::extent<_Rank> &_Extent, const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_buffer) __CPU_ONLY + { + details::_Is_valid_extent(_Extent); + + if (_D3D_buffer == NULL) + { + throw runtime_exception("NULL D3D buffer pointer.", E_INVALIDARG); + } + + if (!details::_Is_D3D_accelerator_view(_Av)) + { + throw runtime_exception("Cannot create D3D buffer on a non-D3D accelerator_view.", E_INVALIDARG); + } + + _Ubiquitous_buffer_ptr _PBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Buffer::_Create_buffer(_D3D_buffer, _Av, _Extent.size(), sizeof(_Value_type))); + return array<_Value_type, _Rank>(_Extent, _Buffer_descriptor(_PBuf->_Get_master_buffer()->_Get_host_ptr(), _PBuf, _Is_array_mode, _Read_write_access)); + } + +} // namespace Concurrency::direct3d + +//============================================================================= +// Atomic Operation Library +//============================================================================= + +#define AS_UINT_PTR(p) reinterpret_cast<unsigned int *>(p) +#define AS_UINT(v) *(reinterpret_cast<unsigned int *>(&(v))) +#define AS_INT(v) *(reinterpret_cast<int *>(&(v))) +#define AS_FLOAT(v) *(reinterpret_cast<float *>(&(v))) + +/// <summary> +/// Performs an atomic addition of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be added to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_add(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic addition of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be added to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_add(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_add(_Dest, _Value); +} + +/// <summary> +/// Performs an atomic subtraction of _Value from the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be subtracted from the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_sub(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret; + int _Neg = -_Value; + _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), AS_UINT(_Neg)); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic subtraction of _Value from the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be subtracted from the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> + +inline unsigned int atomic_fetch_sub(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ +#pragma warning( push ) +#pragma warning( disable : 4146 ) + // Warning 4146: unary minus operator applied to unsigned type, result + // still unsigned. + // + // This is what we want here. The resulted unsigned value have the + // right binary representation for achieving subtraction + return __dp_d3d_interlocked_add(_Dest, (-_Value)); +#pragma warning( pop ) +} + + +/// <summary> +/// Performs an atomic increment to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_inc(_Inout_ int * _Dest) __GPU_ONLY +{ + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), 1U); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic increment to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_inc(_Inout_ unsigned int * _Dest) __GPU_ONLY +{ + return __dp_d3d_interlocked_add(_Dest, 1U); +} + +/// <summary> +/// Performs an atomic decrement to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_dec(_Inout_ int * _Dest) __GPU_ONLY +{ +#pragma warning( push ) +#pragma warning( disable : 4146 ) + // Warning 4146: unary minus operator applied to unsigned type, result + // still unsigned. + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), (-(1U))); + return AS_INT(_Ret); +#pragma warning( pop ) +} + +/// <summary> +/// Performs an atomic decrement to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_dec(_Inout_ unsigned int * _Dest) __GPU_ONLY +{ +#pragma warning( push ) +#pragma warning( disable : 4146 ) + // Warning 4146: unary minus operator applied to unsigned type, result + // still unsigned. + return __dp_d3d_interlocked_add(_Dest, (-(1U))); +#pragma warning( pop ) +} + +/// <summary> +/// Sets the value of location pointed to by _Dest to _Value as an atomic operation +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be set to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_exchange(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_INT(_Ret); +} + +/// <summary> +/// Sets the value of location pointed to by _Dest to _Value as an atomic operation +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be set to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_exchange(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_exchange(_Dest, _Value); +} + +/// <summary> +/// Sets the value of location pointed to by _Dest to _Value as an atomic operation +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be set to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline float atomic_exchange(_Inout_ float * _Dest, float _Value) __GPU_ONLY +{ + unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_FLOAT(_Ret); +} + +/// <summary> +/// Atomically, compares the value pointed to by _Dest for equality with that pointed to by _Expected_value, +/// and if true, returns true and replaces the value with _Value, and if false, returns false and updates the value +/// pointed to by _Expected_value with the value pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Expected_value"> +/// Pointer to the the value being compared to the value pointed to by _Dest. If the comparison is unsuccessful, +/// the value is updated with the value pointed to by _Dest +/// </param> +/// <param name="_Value"> +/// The value to be stored to the location pointed to by _Dest if the comparison is successful +/// </param> +/// <returns> +/// If the operation is successful, return true. Otherwise, false +/// </returns> +inline bool atomic_compare_exchange(_Inout_ int * _Dest, _Inout_ int * _Expected_value, int _Value) __GPU_ONLY +{ + int _Old = *_Expected_value; + unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value), AS_UINT(_Old)); + if (_Ret == AS_UINT(_Old)) + { + return true; + } + else + { + *_Expected_value = AS_INT(_Ret); + return false; + } +} + +/// <summary> +/// Atomically, compares the value pointed to by _Dest for equality with that pointed to by _Expected_value, +/// and if true, returns true and replaces the value with _Value, and if false, returns false and updates the value +/// pointed to by _Expected_value with the value pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Expected_value"> +/// Pointer to the the value being compared to the value pointed to by _Dest. If the comparison is unsuccessful, +/// the value is updated with the value pointed to by _Dest +/// </param> +/// <param name="_Value"> +/// The value to be stored to the location pointed to by _Dest if the comparison is successful +/// </param> +/// <returns> +/// If the operation is successful, return true. Otherwise, false +/// </returns> +inline bool atomic_compare_exchange(_Inout_ unsigned int * _Dest, _Inout_ unsigned int * _Expected_value, unsigned int _Value) __GPU_ONLY +{ + unsigned int _Old = *_Expected_value; + unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(_Dest, _Value, _Old); + if (_Ret == _Old) + { + return true; + } + else + { + *_Expected_value = _Ret; + return false; + } +} + +/// <summary> +/// Atomically computes the maximum of _Value and the value of the memory location pointed to +/// by _Dest, and stores the maximum value to the memory location +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be compared to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_max(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_max_int(_Dest, _Value); +} + +/// <summary> +/// Atomically computes the maximum of _Value and the value of the memory location pointed to +/// by _Dest, and stores the maximum value to the memory location +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be compared to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_max(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_max_uint(_Dest, _Value); +} + + +/// <summary> +/// Atomically computes the minimum of _Value and the value of the memory location pointed to +/// by _Dest, and stores the minimum value to the memory location +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be compared to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_min(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_min_int(_Dest, _Value); +} + +/// <summary> +/// Atomically computes the minimum of _Value and the value of the memory location pointed to +/// by _Dest, and stores the minimum value to the memory location +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to be compared to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_min(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_min_uint(_Dest, _Value); +} + +/// <summary> +/// Performs an atomic bitwise and operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise and to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_and(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_and(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic bitwise and operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise and to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_and(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_and(_Dest, _Value); +} + + +/// <summary> +/// Performs an atomic bitwise or operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise or to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_or(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_or(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic bitwise or operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise or to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_or(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_or(_Dest, _Value); +} + +/// <summary> +/// Performs an atomic bitwise xor operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise xor to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline int atomic_fetch_xor(_Inout_ int * _Dest, int _Value) __GPU_ONLY +{ + unsigned int _Ret; + _Ret = __dp_d3d_interlocked_xor(AS_UINT_PTR(_Dest), AS_UINT(_Value)); + return AS_INT(_Ret); +} + +/// <summary> +/// Performs an atomic bitwise xor operation of _Value to the memory location pointed to by _Dest +/// </summary> +/// <param name="_Dest"> +/// Pointer to the destination location +/// </param> +/// <param name="_Value"> +/// The value to bitwise xor to the location pointed to by _Dest +/// </param> +/// <returns> +/// The original value of the location pointed to by _Dest +/// </returns> +inline unsigned int atomic_fetch_xor(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY +{ + return __dp_d3d_interlocked_xor(_Dest, _Value); +} + +//============================================================================= +// parallel_for_each +//============================================================================= + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain on an accelerator_view. +/// The accelerator_view is determined from the arrays and/or array_views captured by the kernel function, +/// or if no accelerator_view can be derived, the default is chosen. +/// </summary> +/// <param name="_Compute_domain"> +/// An extent which represents the set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "index<_Rank>" which performs the parallel computation. +/// </param> +template <int _Rank, typename _Kernel_type> void parallel_for_each(const extent<_Rank>& _Compute_domain, const _Kernel_type &_Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {accelerator::get_auto_selection_view()}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 3-dimensional +/// regions. The accelerator is determined from the arrays and/or array_views captured by the kernel function, +/// or if no accelerator can be derived, the default is chosen. +/// </summary> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0,_Dim1,_Dim2> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0,_Dim1,_Dim2>" which performs the parallel computation. +/// </param> +template <int _Dim0, int _Dim1, int _Dim2, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0, _Dim1, _Dim2>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {accelerator::get_auto_selection_view()}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 2-dimensional +/// regions. The accelerator is determined from the arrays and/or array_views captured by the kernel function, +/// or if no accelerator can be derived, the default is chosen. +/// </summary> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0,_Dim1> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0,_Dim1>" which performs the parallel computation. +/// </param> +template <int _Dim0, int _Dim1, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0, _Dim1>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {accelerator::get_auto_selection_view()}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 1-dimensional +/// regions. The accelerator is determined from the arrays and/or array_views captured by the kernel function, +/// or if no accelerator can be derived, the default is chosen. +/// </summary> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0>" which performs the parallel computation. +/// </param> +template <int _Dim0, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {accelerator::get_auto_selection_view()}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain on an accelerator. +/// </summary> +/// <param name="_Accl_view"> +/// The accelerator_view upon which to run this parallel computation. +/// </param> +/// <param name="_Compute_domain"> +/// An extent which represents the set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "index<_Rank>" which performs the parallel computation. +/// </param> +template <int _Rank, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const extent<_Rank>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {_Accl_view}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 3-dimensional +/// regions. +/// </summary> +/// <param name="_Accl_view"> +/// The accelerator_view upon which to run this parallel computation. +/// </param> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0,_Dim1,_Dim2> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0,_Dim1,_Dim2>" which performs the parallel computation. +/// </param> +template <int _Dim0, int _Dim1, int _Dim2, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0, _Dim1, _Dim2>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {_Accl_view}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 2-dimensional +/// regions. +/// </summary> +/// <param name="_Accl_view"> +/// The accelerator_view upon which to run this parallel computation. +/// </param> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0,_Dim1> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0,_Dim1>" which performs the parallel computation. +/// </param> +template <int _Dim0, int _Dim1, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0, _Dim1>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {_Accl_view}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + +/// <summary> +/// Invokes a parallel computation of a kernel function over a compute domain that has been tiled into 1-dimensional +/// regions. +/// </summary> +/// <param name="_Accl_view"> +/// The accelerator_view upon which to run this parallel computation. +/// </param> +/// <param name="_Compute_domain"> +/// A tiled_extent<_Dim0> which represents the tiled set of indices that form the compute domain. +/// </param> +/// <param name="_Kernel"> +/// A function object that takes an argument of type "tiled_index<_Dim0>" which performs the parallel computation. +/// </param> +template <int _Dim0, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0>& _Compute_domain, const _Kernel_type& _Kernel) +{ + _Host_Scheduling_info _SchedulingInfo = {_Accl_view}; + details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel); +} + + + +//============================================================================= + +extern "C" +{ + +// Debugging intrinsics +void direct3d_abort() __GPU_ONLY; +void direct3d_errorf(const char *, ...) __GPU_ONLY; +void direct3d_printf(const char *, ...) __GPU_ONLY; + +} + +////////////////////////////////////////////////////////////////////// +/// Memory fences and tile barriers + +#pragma warning( push ) +#pragma warning( disable : 4100 ) // unreferenced formal parameter + +/// <summary> +/// Ensures that memory accesses are visible to other threads in the thread tile, and are executed according to program order +/// </summary> +/// <param name="_Barrier"> +/// A tile_barrier object +/// </param> +inline void all_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY +{ + __dp_d3d_all_memory_fence(); +} + +/// <summary> +/// Ensures that global memory accesses are visible to other threads in the thread tile, and are executed according to program order +/// </summary> +/// <param name="_Barrier"> +/// A tile_barrier object +/// </param> +inline void global_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY +{ + __dp_d3d_device_memory_fence(); +} + +/// <summary> +/// Ensures that tile_static memory accesses are visible to other threads in the thread tile, and are executed according to program order +/// </summary> +/// <param name="_Barrier"> +/// A tile_barrier object +/// </param> +inline void tile_static_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY +{ + __dp_d3d_tile_static_memory_fence(); +} + +#pragma warning( pop ) + + + +namespace direct3d +{ + +/// <summary> +/// Returns the absolute value of the argument +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <returns> +/// Returns the absolute value of the argument +/// </returns> +inline int abs(int _X) __GPU_ONLY +{ + return __dp_d3d_absi(_X); +} + +/// <summary> +/// Clamps _X to the specified _Min and _Max range +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <param name="_Min"> +/// Floating-point value +/// </param> +/// <param name="_Max"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns the clamped value of _X +/// </returns> +inline float clamp(float _X, float _Min, float _Max) __GPU_ONLY +{ + return __dp_d3d_clampf(_X, _Min, _Max); +} + +/// <summary> +/// Clamps _X to the specified _Min and _Max range +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Min"> +/// Integer value +/// </param> +/// <param name="_Max"> +/// Integer value +/// </param> +/// <returns> +/// Returns the clamped value of _X +/// </returns> +inline int clamp(int _X, int _Min, int _Max) __GPU_ONLY +{ + return __dp_d3d_clampi(_X, _Min, _Max); +} + +/// <summary> +/// Counts the number of set bits in _X +/// </summary> +/// <param name="_X"> +/// Unsigned integer value +/// </param> +/// <returns> +/// Returns the number of set bits in _X +/// </returns> +inline unsigned int countbits(unsigned int _X) __GPU_ONLY +{ + return __dp_d3d_countbitsu(_X); +} + +/// <summary> +/// Gets the location of the first set bit in _X, starting from the highest order bit and working downward +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <returns> +/// Returns The location of the first set bit +/// </returns> +inline int firstbithigh(int _X) __GPU_ONLY +{ + return __dp_d3d_firstbithighi(_X); +} + +/// <summary> +/// Gets the location of the first set bit in _X, starting from the lowest order bit and working upward +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <returns> +/// Returns The location of the first set bit +/// </returns> +inline int firstbitlow(int _X) __GPU_ONLY +{ + return __dp_d3d_firstbitlowi(_X); +} + +/// <summary> +/// Determine the maximum numeric value of the arguments +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Y"> +/// Integer value +/// </param> +/// <returns> +/// Return the maximum numeric value of the arguments +/// </returns> +inline int imax(int _X, int _Y) __GPU_ONLY +{ + return __dp_d3d_maxi(_X, _Y); +} + +/// <summary> +/// Determine the minimum numeric value of the arguments +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Y"> +/// Integer value +/// </param> +/// <returns> +/// Return the minimum numeric value of the arguments +/// </returns> +inline int imin(int _X, int _Y) __GPU_ONLY +{ + return __dp_d3d_mini(_X, _Y); +} + +/// <summary> +/// Determine the maximum numeric value of the arguments +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Y"> +/// Integer value +/// </param> +/// <returns> +/// Return the maximum numeric value of the arguments +/// </returns> +inline unsigned int umax(unsigned int _X, unsigned int _Y) __GPU_ONLY +{ + return __dp_d3d_maxu(_X, _Y); +} + +/// <summary> +/// Determine the minimum numeric value of the arguments +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Y"> +/// Integer value +/// </param> +/// <returns> +/// Return the minimum numeric value of the arguments +/// </returns> +inline unsigned int umin(unsigned int _X, unsigned int _Y) __GPU_ONLY +{ + return __dp_d3d_minu(_X, _Y); +} + +/// <summary> +/// Performs an arithmetic multiply/add operation on three arguments: _X * _Y + _Z +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <param name="_Y"> +/// Floating-point value +/// </param> +/// <param name="_Z"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns _X * _Y + _Z +/// </returns> +inline float mad(float _X, float _Y, float _Z) __GPU_ONLY +{ + return __dp_d3d_madf(_X, _Y, _Z); +} + +/// <summary> +/// Performs an arithmetic multiply/add operation on three arguments: _X * _Y + _Z +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <param name="_Y"> +/// Floating-point value +/// </param> +/// <param name="_Z"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns _X * _Y + _Z +/// </returns> +inline double mad(double _X, double _Y, double _Z) __GPU_ONLY +{ + return __dp_d3d_madd(_X, _Y, _Z); +} + +/// <summary> +/// Performs an arithmetic multiply/add operation on three arguments: _X * _Y + _Z +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <param name="_Y"> +/// Integer value +/// </param> +/// <param name="_Z"> +/// Integer value +/// </param> +/// <returns> +/// Returns _X * _Y + _Z +/// </returns> +inline int mad(int _X, int _Y, int _Z) __GPU_ONLY +{ + return __dp_d3d_madi(_X, _Y, _Z); +} + +/// <summary> +/// Performs an arithmetic multiply/add operation on three arguments: _X * _Y + _Z +/// </summary> +/// <param name="_X"> +/// Unsigned integer value +/// </param> +/// <param name="_Y"> +/// Unsigned integer value +/// </param> +/// <param name="_Z"> +/// Unsigned integer value +/// </param> +/// <returns> +/// Returns _X * _Y + _Z +/// </returns> +inline unsigned int mad(unsigned int _X, unsigned int _Y, unsigned int _Z) __GPU_ONLY +{ + return __dp_d3d_madu(_X, _Y, _Z); +} + +/// <summary> +/// Generates a random value using the Perlin noise algorithm +/// </summary> +/// <param name="_X"> +/// Floating-point value from which to generate Perlin noise +/// </param> +/// <returns> +/// Returns The Perlin noise value within a range between -1 and 1 +/// </returns> +inline float noise(float _X) __GPU_ONLY +{ + return __dp_d3d_noisef(_X); +} + +/// <summary> +/// Converts _X from degrees to radians +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns _X converted from degrees to radians +/// </returns> +inline float radians(float _X) __GPU_ONLY +{ + return __dp_d3d_radiansf(_X); +} + +/// <summary> +/// Calculates a fast, approximate reciprocal of the argument +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns a fast, approximate reciprocal of the argument +/// </returns> +inline float rcp(float _X) __GPU_ONLY +{ + return __dp_d3d_rcpf(_X); +} + +/// <summary> +/// Reverses the order of the bits in _X +/// </summary> +/// <param name="_X"> +/// Unsigned integer value +/// </param> +/// <returns> +/// Returns the value with the bit order reversed in _X +/// </returns> +inline unsigned int reversebits(unsigned int _X) __GPU_ONLY +{ + return __dp_d3d_reversebitsu(_X); +} + +/// <summary> +/// Clamps _X within the range of 0 to 1 +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns _X clamped within the range of 0 to 1 +/// </returns> +inline float saturate(float _X) __GPU_ONLY +{ + return __dp_d3d_saturatef(_X); +} + +/// <summary> +/// Returns the sign of the argument +/// </summary> +/// <param name="_X"> +/// Integer value +/// </param> +/// <returns> +/// Returns the sign of the argument +/// </returns> +inline int sign(int _X) __GPU_ONLY +{ + return __dp_d3d_signi(_X); +} + +/// <summary> +/// Returns a smooth Hermite interpolation between 0 and 1, if _X is in the range [_Min, _Max]. +/// </summary> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <param name="_Min"> +/// Floating-point value +/// </param> +/// <param name="_Max"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns 0 if _X is less than _Min; 1 if _X is greater than _Max; otherwise, a value between 0 and 1 if _X is in the range [_Min, _Max] +/// </returns> +inline float smoothstep(float _Min, float _Max, float _X) __GPU_ONLY +{ + return __dp_d3d_smoothstepf(_Min, _Max, _X); +} + +/// <summary> +/// Compares two values, returning 0 or 1 based on which value is greater +/// </summary> +/// <param name="_Y"> +/// Floating-point value +/// </param> +/// <param name="_X"> +/// Floating-point value +/// </param> +/// <returns> +/// Returns 1 if the _X is greater than or equal to _Y; otherwise, 0 +/// </returns> +inline float step(float _Y, float _X) __GPU_ONLY +{ + return __dp_d3d_stepf(_Y, _X); +} + +} // namespace Concurrency::direct3d + +} // namespace Concurrency + +#include <xxamp_inl.h> + +namespace concurrency = Concurrency; + +#pragma pack(pop) +// End of file diff --git a/test_data/lots_of_files/amp_graphics.h b/test_data/lots_of_files/amp_graphics.h new file mode 100644 index 0000000..fa46ada --- /dev/null +++ b/test_data/lots_of_files/amp_graphics.h @@ -0,0 +1,4942 @@ +/*** +* ==++== +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* ==--== +* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +* +* amp_graphics.h +* +* C++ AMP Graphics Library +* +* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +****/ + +#pragma once + +#include <amp_short_vectors.h> +#include <array> +#include <dxgiformat.h> +#include <sstream> + +#define _AMP_GRAPHICS_H + +namespace Concurrency +{ + +namespace graphics +{ + +namespace details +{ + +#pragma warning( push ) +#pragma warning( disable : 6326 ) // Potential comparison of a constant with another constant + +template<typename _Ty> +struct _Short_vector_type_traits +{ + typedef void _Scalar_type; + static const bool _Is_valid_SVT_for_texture = false; + static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type; + static const unsigned int _Num_channels = 0; + static const unsigned int _Default_bits_per_channel = 0; +}; + +template<> +struct _Short_vector_type_traits<unsigned int> +{ + typedef unsigned int _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type; + static const unsigned int _Num_channels = 1; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<uint_2> +{ + typedef uint_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<uint_3> +{ + typedef uint_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type; + static const unsigned int _Num_channels = 3; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<uint_4> +{ + typedef uint_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<int> +{ + typedef int _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Int_type; + static const unsigned int _Num_channels = 1; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<int_2> +{ + typedef int_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Int_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<int_3> +{ + typedef int_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Int_type; + static const unsigned int _Num_channels = 3; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<int_4> +{ + typedef int_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Int_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 32; +}; + + +template<> +struct _Short_vector_type_traits<float> +{ + typedef float _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Float_type; + static const unsigned int _Num_channels = 1; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<float_2> +{ + typedef float_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Float_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<float_3> +{ + typedef float_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Float_type; + static const unsigned int _Num_channels = 3; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<float_4> +{ + typedef float_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Float_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<unorm> +{ + typedef unorm _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type; + static const unsigned int _Num_channels = 1; + static const unsigned int _Default_bits_per_channel = 16; +}; + +template<> +struct _Short_vector_type_traits<unorm_2> +{ + typedef unorm_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 16; +}; + +template<> +struct _Short_vector_type_traits<unorm_3> +{ + typedef unorm_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = false; + static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type; + static const unsigned int _Num_channels = 0; + static const unsigned int _Default_bits_per_channel = 0; +}; + +template<> +struct _Short_vector_type_traits<unorm_4> +{ + typedef unorm_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 16; +}; + +template<> +struct _Short_vector_type_traits<norm> +{ + typedef norm _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type; + static const unsigned int _Num_channels = 1; + static const unsigned int _Default_bits_per_channel = 16; +}; + +template<> +struct _Short_vector_type_traits<norm_2> +{ + typedef norm_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 16; +}; + +template<> +struct _Short_vector_type_traits<norm_3> +{ + typedef norm_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = false; + static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type; + static const unsigned int _Num_channels = 0; + static const unsigned int _Default_bits_per_channel = 0; +}; + +template<> +struct _Short_vector_type_traits<norm_4> +{ + typedef norm_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 16; +}; + + +template<> +struct _Short_vector_type_traits<double> +{ + typedef double _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Double_type; + static const unsigned int _Num_channels = 2; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<double_2> +{ + typedef double_2::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = true; + static const _Short_vector_base_type_id _Format_base_type_id = _Double_type; + static const unsigned int _Num_channels = 4; + static const unsigned int _Default_bits_per_channel = 32; +}; + +template<> +struct _Short_vector_type_traits<double_3> +{ + typedef double_3::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = false; + static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type; + static const unsigned int _Num_channels = 0; + static const unsigned int _Default_bits_per_channel = 0; +}; + +template<> +struct _Short_vector_type_traits<double_4> +{ + typedef double_4::value_type _Scalar_type; + static const bool _Is_valid_SVT_for_texture = false; + static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type; + static const unsigned int _Num_channels = 0; + static const unsigned int _Default_bits_per_channel = 0; +}; + +template<typename _Short_vector_type> +unsigned int _Get_default_bits_per_scalar_element() +{ + return _Short_vector_type_traits<_Short_vector_type>::_Format_base_type_id == _Double_type ? + _Short_vector_type_traits<_Short_vector_type>::_Default_bits_per_channel * 2 : + _Short_vector_type_traits<_Short_vector_type>::_Default_bits_per_channel; +} + +template<int _Rank> +std::array<size_t, 3> _Get_dimensions(const Concurrency::extent<_Rank> & _Ext, unsigned int _Mip_offset) +{ + std::array<size_t, 3> _Arr; + // For un-used dimensions, use value 1. + switch((_Rank)) { + case 1: + _Arr[0] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U); + _Arr[1] = 1; + _Arr[2] = 1; + break; + case 2: + _Arr[0] = static_cast<size_t>((_Ext[1] >> _Mip_offset) ? (_Ext[1] >> _Mip_offset) : 1U); + _Arr[1] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U); + _Arr[2] = 1; + break; + case 3: + _Arr[0] = static_cast<size_t>((_Ext[2] >> _Mip_offset) ? (_Ext[2] >> _Mip_offset) : 1U); + _Arr[1] = static_cast<size_t>((_Ext[1] >> _Mip_offset) ? (_Ext[1] >> _Mip_offset) : 1U); + _Arr[2] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U); + break; + default: + _ASSERTE(false); + _Arr[0] = 1; + _Arr[1] = 1; + _Arr[2] = 1; + break; + } + return _Arr; +} + +template <int _Rank> +std::array<size_t, 3> _Get_indices(const index<_Rank> &_Idx) +{ + std::array<size_t, 3> _Arr; + // For un-used dimensions, use value 0. + switch((_Rank)) { + case 1: + _Arr[0] = static_cast<size_t>(_Idx[0]); + _Arr[1] = 0; + _Arr[2] = 0; + break; + case 2: + _Arr[0] = static_cast<size_t>(_Idx[1]); + _Arr[1] = static_cast<size_t>(_Idx[0]); + _Arr[2] = 0; + break; + case 3: + _Arr[0] = static_cast<size_t>(_Idx[2]); + _Arr[1] = static_cast<size_t>(_Idx[1]); + _Arr[2] = static_cast<size_t>(_Idx[0]); + break; + default: + _ASSERTE(false); + _Arr[0] = 0; + _Arr[1] = 0; + _Arr[2] = 0; + break; + } + return _Arr; +} + +template<int _Rank> +Concurrency::extent<_Rank> _Create_extent(size_t _Width, size_t _Height, size_t _Depth) +{ + extent<_Rank> _Ext; + switch((_Rank)) { + case 1: + _Ext[0] = static_cast<int>(_Width); + break; + case 2: + _Ext[0] = static_cast<int>(_Height); + _Ext[1] = static_cast<int>(_Width); + break; + case 3: + _Ext[0] = static_cast<int>(_Depth); + _Ext[1] = static_cast<int>(_Height); + _Ext[2] = static_cast<int>(_Width); + break; + default: + _ASSERTE(false); + break; + } + return _Ext; +} + +// forward declaration +template <typename _Value_type, int _Rank> class _Texture_base; +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const void * _Src, unsigned int _Src_byte_size, const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Offset, const Concurrency::extent<_Rank> &_Copy_extent); +template <typename OutputIterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank> &_Src, OutputIterator _Dest_iter); + +template<typename _Value_type, int _Rank> +_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset, + const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent); + +// The base class for texture, writeonly_texture_view +template <typename _Value_type, int _Rank> +class _Texture_base +{ + static_assert(_Rank > 0 && _Rank <= 3, "texture is only supported for rank 1, 2, and 3."); + static_assert(_Short_vector_type_traits<typename std::remove_const<_Value_type>::type>::_Is_valid_SVT_for_texture, "invalid value_type for a texture."); + + // Friends + template<typename _T> + friend const _Texture_descriptor& Concurrency::details::_Get_texture_descriptor(const _T& _Tex) __GPU; + template<typename _T> + friend _Ret_ _Texture* Concurrency::details::_Get_texture(const _T& _Tex) __CPU_ONLY; + template<typename _Value_type, int _Rank> + friend _Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset, + const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent) __CPU_ONLY; + +public: + static const int rank = _Rank; + typedef typename _Value_type value_type; + typedef typename _Short_vector_type_traits<_Value_type>::_Scalar_type scalar_type; + +public: + /// <summary> + /// Returns the extent that defines the shape of this texture or texture view. + /// </summary> + __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent; + Concurrency::extent<_Rank> get_extent() const __GPU + { + return _M_extent; + } + + /// <summary> + /// Returns the extent for specific mipmap level of this texture or texture view. + /// </summary> + /// <param> + /// Mipmap level for which extent should be calculated. + /// </param> + Concurrency::extent<_Rank> get_mipmap_extent(unsigned int _Mipmap_level) const __CPU_ONLY + { + if (_Mipmap_level >= this->get_mipmap_levels()) + { + std::stringstream _Err_msg; + _Err_msg << "Value for _Mipmap_level parameter (" << _Mipmap_level + << ") cannot be greater than or equal to number of mipmap levels (" + << this->get_mipmap_levels() << ") on the texture or texture view"; + + throw runtime_exception(_Err_msg.str().c_str(), E_INVALIDARG); + } + return Concurrency::details::_Get_extent_at_level(_M_extent, _Mipmap_level); + } + + /// <summary> + /// Returns the extent for specific mipmap level of this texture or texture view. + /// </summary> + /// <param> + /// Mipmap level for which extent should be calculated. + /// </param> + Concurrency::extent<_Rank> get_mipmap_extent(unsigned int _Mipmap_level) const __GPU_ONLY + { + return Concurrency::details::_Get_extent_at_level_unsafe(_M_extent, _Mipmap_level); + } + + /// <summary> + /// Returns the accelerator_view where this texture or texture view is located. + /// </summary> + __declspec(property(get=get_accelerator_view)) Concurrency::accelerator_view accelerator_view; + Concurrency::accelerator_view get_accelerator_view() const __CPU_ONLY + { + return _Get_texture()->_Get_access_on_accelerator_view(); + } + + /// <summary> + /// Returns the number of bits per scalar element + /// </summary> + __declspec(property(get=get_bits_per_scalar_element)) unsigned int bits_per_scalar_element; + unsigned int get_bits_per_scalar_element() const __CPU_ONLY + { + unsigned int _Bits_per_channel = _Get_texture()->_Get_bits_per_channel(); + return _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type ? _Bits_per_channel * (sizeof(double)/sizeof(int)) : _Bits_per_channel; + } + + /// <summary> + /// Query how many mipmap levels are accessible by this texture (or texture view). + /// </summary> + /// <returns> + /// Returns number of mipmap levels accessible by this texture (or texture view). + /// </returns> + __declspec(property(get=get_mipmap_levels)) unsigned int mipmap_levels; + unsigned int get_mipmap_levels() const __GPU + { + return _M_texture_descriptor._Get_view_mipmap_levels(); + } + + /// <summary> + /// Returns the physical data length (in bytes) that is required in order to represent + /// the texture on the host side with its native format. + /// If the texture contains multiple mipmap levels the value represents the sum of physical data length for each accessible mipmap level by this texture (or texture view). + /// </summary> + __declspec(property(get=get_data_length)) unsigned int data_length; + unsigned int get_data_length() const __CPU_ONLY + { + return _Get_texture()->_Get_data_length(this->_Get_most_detailed_mipmap_level(), this->get_mipmap_levels()); + } + +protected: + // internal storage abstraction + typedef Concurrency::details::_Texture_descriptor _Texture_descriptor; + + _Texture_base() __CPU_ONLY + { + // This default ctor is required to enable move ctor for a derived types, + // empty _Texture_base is later initialized by move assigment operator + } + + _Texture_base(const Concurrency::extent<_Rank>& _Ext, unsigned int _Mipmap_levels = 1) __CPU_ONLY + : _M_extent(_Ext), _M_texture_descriptor(/*_Most_detailed_mipmap_level=*/0, _Mipmap_levels) + { + _Is_valid_extent(_M_extent); + _Are_valid_mipmap_parameters(/*_Most_detailed_mipmap_level=*/0, _Mipmap_levels); + + // Validate if we can generate _Mipmap_levels number of mipmap levels given the dimensionality of the texture + unsigned int _Max_mipmap_levels = _Get_max_mipmap_levels(_M_extent); + if (_Mipmap_levels > _Max_mipmap_levels) + { + std::stringstream _Err_msg; + _Err_msg << "The texture extent is too small to generate (" << _Mipmap_levels << ") mipmap levels, the maximum allowed is (" << _Max_mipmap_levels << ")"; + throw runtime_exception(_Err_msg.str().c_str(), E_INVALIDARG); + } + else if (_Mipmap_levels == 0) + { + // Generate full range of all mipmaps + // e.g. 2D 10x2 texture would have: 10x2, 5x1, 2x1, 1x1 (4 mipmap levels) + _Mipmap_levels = _Max_mipmap_levels; + } + _M_texture_descriptor._Set_view_mipmap_levels(_Mipmap_levels); + } + + // shallow copy for texture_views + _Texture_base(const _Texture_base & _Src) __GPU + : _M_extent(_Src._M_extent), _M_texture_descriptor(_Src._M_texture_descriptor) + { + } + + // shallow copy for texture_views that redefine range of mipmaps + _Texture_base(const _Texture_base & _Src, unsigned int _Most_detailed_mipmap_level, unsigned int _View_mipmap_levels) __CPU_ONLY + : _M_extent(_Get_extent_at_level(_Src.extent, _Most_detailed_mipmap_level)), _M_texture_descriptor(_Src._M_texture_descriptor, _Src._Get_most_detailed_mipmap_level() + _Most_detailed_mipmap_level, _View_mipmap_levels) + { + Concurrency::details::_Is_valid_mipmap_range(_Src.get_mipmap_levels(), _Most_detailed_mipmap_level, _View_mipmap_levels); + } + + // shallow copy for texture_views that in restrict(amp) context, the texture views can no longer redefine mipmap range, + // but read-write texture view needs to flatten to single mipmap level when created over a texture with multiple mipmap levels. + _Texture_base(const _Texture_base & _Src, bool _Flatten_mipmap_levels) __GPU_ONLY + : _M_extent(_Src.extent), _M_texture_descriptor(_Src._M_texture_descriptor, /*_Most_detailed_mipmap_level=*/0, _Flatten_mipmap_levels ? /*_View_mipmap_levels=*/1 : _Src.get_mipmap_levels()) + { + } + + // interop + _Texture_base(const Concurrency::extent<_Rank>& _Ext, const _Texture_descriptor & _Desc) __CPU_ONLY + : _M_extent(_Ext), _M_texture_descriptor(_Desc) + { + Concurrency::details::_Is_valid_extent(_M_extent); + } + + void _Copy_to(const _Texture_base & _Dest) const __CPU_ONLY + { + if (!(*this == _Dest)) + { + _ASSERTE(this->extent == _Dest.extent); + details::_Copy_async_impl(*this, index<_Rank>(), _Dest, index<_Rank>(), _Dest.extent)._Get(); + } + } + + bool operator==(const _Texture_base & _Other) const __CPU_ONLY + { + return _Other._M_extent == _M_extent && _Other._M_texture_descriptor == _M_texture_descriptor; + } + + ~_Texture_base() __GPU + { + } + + _Ret_ _Texture* _Get_texture() const __CPU_ONLY + { + return _M_texture_descriptor._Get_texture_ptr(); + } + + unsigned int _Get_most_detailed_mipmap_level() const __GPU + { + return _M_texture_descriptor._Get_most_detailed_mipmap_level(); + } + + bool _Are_mipmap_levels_overlapping(const _Texture_base &_Other) const __CPU_ONLY + { + return _M_texture_descriptor._Are_mipmap_levels_overlapping(&_Other._M_texture_descriptor); + } + +protected: + Concurrency::extent<_Rank> _M_extent; + _Texture_descriptor _M_texture_descriptor; +}; + +inline void _Is_valid_data_length(unsigned int _Num_elems, unsigned int _Bits_per_elem) +{ + unsigned long long _Bytes_per_elem = static_cast<unsigned long long>(_Bits_per_elem / 8U); + unsigned long long _Total_bytes = static_cast<unsigned long long>(_Num_elems) * _Bytes_per_elem; + if (_Total_bytes > static_cast<unsigned long long>(UINT_MAX)) + { + throw runtime_exception("Invalid - texture data_length exceeds UINT_MAX", E_INVALIDARG); + } +} + +} // namespace details + + +using Concurrency::graphics::details::_Short_vector_type_traits; + +// forward declarations +template <typename _Value_type, int _Rank> +class texture; +template <typename _Value_type, int _Rank> +class writeonly_texture_view; +template <typename _Value_type, int _Rank> +class texture_view; +class sampler; + +namespace direct3d +{ +template<typename _Value_type, int _Rank> +texture<_Value_type, _Rank> make_texture(const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_texture, DXGI_FORMAT _View_format = DXGI_FORMAT_UNKNOWN) __CPU_ONLY; + +sampler make_sampler(_In_ IUnknown *_D3D_sampler) __CPU_ONLY; +_Ret_ IUnknown * get_sampler(const Concurrency::accelerator_view &_Av, const sampler &_Sampler) __CPU_ONLY; + +} // namespace direct3d + +/// <summary> +/// A texture is a data aggregate on an accelerator_view in the extent domain. +/// It is a collection of variables, one for each element in an extent domain. +/// Each variable holds a value corresponding to C++ primitive type (unsigned int, +/// int, float, double), or scalar type norm, or unorm (defined in concurrency::graphics), +/// or eligible short vector types defined in concurrency::graphics. +/// </summary> +/// <param name="_Value_type"> +/// The type of the elements in the texture aggregates. +/// </param> +/// <param name="_Rank"> +/// The _Rank of the corresponding extent domain. +/// </param> +template <typename _Value_type, int _Rank> class texture : public details::_Texture_base<_Value_type, _Rank> +{ + template<typename _Value_type, int _Rank> + friend texture<_Value_type,_Rank> direct3d::make_texture(const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_texture, DXGI_FORMAT _View_format) __CPU_ONLY; + + static_assert(!std::is_const<_Value_type>::value, "const value type is not supported for texture."); + +public: + + /// <summary> + /// Construct a texture from extents. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the texture. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view); + } + + /// <summary> + /// Construct texture<T,1> with the extent _E0 + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + texture(int _E0) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view); + } + + /// <summary> + /// Construct a texture<T,2> from two integer extents. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + texture(int _E0, int _E1) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view); + } + + /// <summary> + /// Construct a texture<T,3> from three integer extents. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + texture(int _E0, int _E1, int _E2) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view); + } + + /// <summary> + /// Construct a texture from extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Extent"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av); + } + + /// <summary> + /// Construct a staging texture from extents, bound to a specific accelerator_view + /// and an associated accelerator_view that is the preferred location for copying + /// to/from this texture. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av); + } + + /// <summary> + /// Construct a texture<T,1> with the extent _E0, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, accelerator_view) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av); + } + + /// <summary> + /// Construct a staging texture<T,1> with the extent _E0, bound to a specific + /// accelerator_view and an associated accelerator_view that is the preferred location + /// for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av); + } + + /// <summary> + /// Construct a texture<T,2> from two integer extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, accelerator_view) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av); + } + + /// <summary> + /// Construct a staging texture<T,2> from two integer extents, bound to a + /// specific accelerator_view and an associated accelerator_view that is the + /// preferred location for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av); + } + + /// <summary> + /// Construct a texture<T,3> from three integer extents, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, int _E2, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, accelerator_view) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av); + } + + /// <summary> + /// Construct a staging texture<T,3> from three integer extents, bound to a + /// specific accelerator_view and an associated accelerator_view that is the preferred + /// location for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, int _E2, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av); + } + + /// <summary> + /// Construct a texture initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template<typename _Input_iterator> texture(const Concurrency::extent<_Rank>& _Ext, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture<T,1> with the extent _E0 and from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template<typename _Input_iterator> texture(int _E0, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, iterator, iterator) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture<T,2> with two integers and initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, iterator, iterator) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Src_first, _Src_last); + } + + + /// <summary> + /// Construct a texture<T,3> with three integers and initialized from a pair of iterators into a container. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, int _E2, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, iterator, iterator) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + template<typename _Input_iterator> texture(const Concurrency::extent<_Rank>& _Ext, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging texture initialized from a pair of iterators into a container, + /// bound to a specific accelerator_view and an associated accelerator_view that is the + /// preferred location for copying to/from this texture. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + template<typename _Input_iterator> texture(const Concurrency::extent<_Rank>& _Ext, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(_Ext) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture<T,1> with integer _E0 and initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + template<typename _Input_iterator> texture(int _E0, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, iterator, iterator, accelerator_view) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging texture<T,1> with integer _E0 and initialized from a pair of iterators + /// into a container, bound to a specific accelerator_view and an associated accelerator_view that is + /// the preferred location for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + template<typename _Input_iterator> texture(int _E0, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on texture<value_type, 1>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture<T,2> with two integers and initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, iterator, iterator, accelerator_view) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging texture<T,2> with two integers and initialized from a pair of iterators + /// into a container, bound to a specific accelerator_view and an associated accelerator_view that is + /// the preferred location for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on texture<value_type, 2>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture<T,3> with three integers and initialized from a pair of iterators into a container, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, int _E2, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, iterator, iterator, accelerator_view) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a staging texture<T,3> with three integers and initialized from a pair of iterators + /// into a container, bound to a specific accelerator_view and an associated accelerator_view that is the + /// preferred location for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Src_last"> + /// An ending iterator into the source container. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + template<typename _Input_iterator> texture(int _E0, int _E1, int _E2, _Input_iterator _Src_first, _Input_iterator _Src_last, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on texture<value_type, 3>."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "texture cannot be constructed from unorm based short vectors via this constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "texture cannot be constructed from norm based short vectors via this constructor."); + _Initialize(_Av, _Associated_av, _Src_first, _Src_last); + } + + /// <summary> + /// Construct a texture from extents and specified bits per scalar element + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture from extents, specified bits per scalar element and number of mipmap levels + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Mipmap_levels"> + /// Number of mipmap levels in the underlying texture. + /// If 0 is specified, the texture will have full range of mipmap levels down to smallest possible size for the given extent. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, unsigned int _Bits_per_scalar_element, unsigned int _Mipmap_levels) __CPU_ONLY + : _Texture_base(_Ext, _Mipmap_levels) + { + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,1> with integer _E0 and specified bits per scalar element + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, unsigned int) is only permissible on texture<value_type, 1>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,2> with two integers and specified bits per scalar element + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, int _E1, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, unsigned int) is only permissible on texture<value_type, 2>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,3> with three integers and specified bits per scalar element + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the next-to-most-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Src_first"> + /// A beginning iterator into the source container. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, int _E1, int _E2, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, unsigned int) is only permissible on texture<value_type, 3>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Bits_per_scalar_element); + } + + + /// <summary> + /// Construct a texture from extents and specified bits per scalar element, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(_Av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture from extents, specified bits per scalar element and number of mipmap levels + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Mipmap_levels"> + /// Number of mipmap levels in the underlying texture. + /// If 0 is specified, the texture will have full range of mipmap levels down to smallest possible size for the given extent. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, unsigned int _Bits_per_scalar_element, unsigned int _Mipmap_levels, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(_Ext, _Mipmap_levels) + { + _Initialize(_Av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture from extents and specified bits per scalar element, bound to a + /// specific accelerator_view and an associated accelerator_view that is the preferred location + /// for copying to/from this texture. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(_Av, _Associated_av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T, 1> with integer _E0 and specified bits per scalar element, bound to a specific accelerator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, unsigned int, accelerator_view) is only permissible on texture<value_type, 1>."); + _Initialize(_Av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T, 1> with integer _E0 and specified bits per scalar element, + /// bound to a specific accelerator and an associated accelerator_view that is the preferred location + /// for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 1>."); + _Initialize(_Av, _Associated_av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,2> with two integers and specified bits per scalar element, bound to a specific accelerator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, unsigned int, accelerator_view) is only permissible on texture<value_type, 2>."); + _Initialize(_Av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T,2> with two integers and specified bits per scalar element, + /// bound to a specific accelerator and an associated accelerator_view that is the preferred location + /// for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 2>."); + _Initialize(_Av, _Associated_av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,3> with three integers and specified bits per scalar element, bound to a specific accelerator. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, int _E2, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, unsigned int, accelerator_view) is only permissible on texture<value_type, 3>."); + _Initialize(_Av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T,3> with three integers and specified bits per scalar element, + /// bound to a specific accelerator and an associated accelerator_view that is the preferred location + /// for copying to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, int _E2, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 3>."); + _Initialize(_Av, _Associated_av, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture from extents and specified bits per scalar element, initialized from a host buffer. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,1> with integer _E0 and specified bits per scalar element, initialized from a host buffer. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, void *, unsigned int, unsigned int) is only permissible on texture<value_type, 1>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T,2> with two integers and specified bits per scalar element, initialized from a host buffer. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, int _E1, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, void *, unsigned int, unsigned int) is only permissible on texture<value_type, 2>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + + /// <summary> + /// Construct a texture<T,3> with three integers and specified bits per scalar element, initialized from a host buffer. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + texture(int _E0, int _E1, int _E2, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, void *, unsigned int, unsigned int) is only permissible on texture<value_type, 3>."); + _Initialize(Concurrency::details::_Select_default_accelerator().default_view, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture from extents and specified bits per scalar element, initialized from a host buffer, bound to a specific accelerator_view. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(_Av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture from extents and specified bits per scalar element, initialized from a host buffer, + /// bound to a specific accelerator_view and an associated accelerator_view that is the preferred location for copying + /// to/from this texture. + /// </summary> + /// <param name="_Ext"> + /// An extent that describes the shape of the texture. + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const Concurrency::extent<_Rank>& _Ext, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(_Ext) + { + _Initialize(_Av, _Associated_av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T, 1> with integer _E0 and specified bits per scalar element, initialized from a host buffer, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, void *, unsigned int, unsigned int, accelerator_view) is only permissible on texture<value_type, 1>."); + _Initialize(_Av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T, 1> with integer _E0 and specified bits per scalar element, initialized from a host buffer, + /// bound to a specific accelerator_view and an associated accelerator_view that is the preferred location for copying + /// to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0)) + { + static_assert(_Rank == 1, "texture(int, void *, unsigned int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 1>."); + _Initialize(_Av, _Associated_av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T, 2> with two integers and specified bits per scalar element, initialized from a host buffer, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, void *, unsigned int, unsigned int, accelerator_view) is only permissible on texture<value_type, 2>."); + _Initialize(_Av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T, 2> with two integers and specified bits per scalar element, initialized from a host buffer, + /// bound to a specific accelerator_view and an associated accelerator_view that is the preferred location for copying + /// to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (height). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1)) + { + static_assert(_Rank == 2, "texture(int, int, void *, unsigned int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 2>."); + _Initialize(_Av, _Associated_av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture<T, 3> with three integers and specified bits per scalar element, initialized from a host buffer, bound to a specific accelerator_view. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(int _E0, int _E1, int _E2, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, void *, unsigned int, unsigned int, accelerator_view) is only permissible on texture<value_type, 3>."); + _Initialize(_Av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a staging texture<T, 3> with three integers and specified bits per scalar element, initialized from a host buffer, + /// bound to a specific accelerator_view and an associated accelerator_view that is the preferred location for copying + /// to/from this texture. + /// </summary> + /// <param name="_E0"> + /// An integer that is the length of the most-significant dimension of this texture (depth). + /// </param> + /// <param name="_E1"> + /// An integer that is the length of the least-significant dimension of this texture (height). + /// </param> + /// <param name="_E2"> + /// An integer that is the length of the least-significant dimension of this texture (width). + /// </param> + /// <param name="_Source"> + /// A pointer to a host buffer. + /// </param> + /// <param name="_Source_byte_size"> + /// Number of bytes in the source buffer. + /// </param> + /// <param name="_Bits_per_scalar_element"> + /// Number of bits per each scalar element in the underlying scalar type of the texture. + /// In general, supported value is 8, 16, 32, 64. + /// If 0 is specified, the number of bits picks defaulted value for the underlying scalar_type. + /// 64 is only valid for double based textures + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(int _E0, int _E1, int _E2, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element, const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + : _Texture_base(Concurrency::extent<_Rank>(_E0, _E1, _E2)) + { + static_assert(_Rank == 3, "texture(int, int, int, void *, unsigned int, unsigned int, accelerator_view, accelerator_view) is only permissible on texture<value_type, 3>."); + _Initialize(_Av, _Associated_av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + /// <summary> + /// Construct a texture from a texture_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture_view to copy from. + /// </param> + texture(const texture_view<_Value_type, _Rank> & _Src) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Src.accelerator_view, _Src); + } + + /// <summary> + /// Construct a texture from a read-only texture_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The read-only texture_view to copy from. + /// </param> + texture(const texture_view<const _Value_type, _Rank> & _Src) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Src.accelerator_view, _Src); + } + + /// <summary> + /// Construct a texture from a texture_view on another accelerator_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture_view to copy from. + /// </param> + /// <param name="_Acc_view"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const texture_view<_Value_type, _Rank> & _Src, const Concurrency::accelerator_view & _Acc_view) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Acc_view, _Src); + } + + /// <summary> + /// Construct a texture from a read-only texture_view on another accelerator_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The read-only texture_view to copy from. + /// </param> + /// <param name="_Acc_view"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const texture_view<const _Value_type, _Rank> & _Src, const Concurrency::accelerator_view & _Acc_view) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Acc_view, _Src); + } + + /// <summary> + /// Construct a staging texture from a texture_view on another accelerator_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture_view to copy from. + /// </param> + /// <param name="_Acc_view"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const texture_view<_Value_type, _Rank> & _Src, const Concurrency::accelerator_view & _Acc_view, const Concurrency::accelerator_view& _Associated_av) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Acc_view, _Associated_av, _Src); + } + + /// <summary> + /// Construct a staging texture from a read-only texture_view on another accelerator_view. Deep copy + /// </summary> + /// <param name="_Src"> + /// The read-only texture_view to copy from. + /// </param> + /// <param name="_Acc_view"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const texture_view<const _Value_type, _Rank> & _Src, const Concurrency::accelerator_view & _Acc_view, const Concurrency::accelerator_view& _Associated_av) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Acc_view, _Associated_av, _Src); + } + + /// <summary> + /// Copy constructor. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture to copy from. + /// </param> + texture(const texture & _Src) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Src.accelerator_view, _Src.associated_accelerator_view, _Src); + } + + /// <summary> + /// Move constructor + /// </summary> + /// <param name="_Other"> + /// The source texture to move from. + /// </param> + texture(texture && _Other) + { + *this = std::move(_Other); + } + + /// <summary> + /// Copy constructor. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture to copy from. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + texture(const texture & _Src, const Concurrency::accelerator_view & _Av) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Av, _Src); + } + + /// <summary> + /// Copy constructor. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture to copy from. + /// </param> + /// <param name="_Av"> + /// An accelerator_view where this texture resides. + /// </param> + /// <param name="_Associated_av"> + /// An accelerator_view which specifies the preferred target location for copies + /// to/from the texture. + /// </param> + texture(const texture & _Src, const Concurrency::accelerator_view & _Av, const Concurrency::accelerator_view& _Associated_av) + : _Texture_base(_Src.extent, _Src.get_mipmap_levels()) + { + _Initialize(_Av, _Associated_av, _Src); + } + + /// <summary> + /// Copy assignment operator. Deep copy + /// </summary> + /// <param name="_Src"> + /// The texture to copy from. + /// </param> + /// <returns> + /// A reference to this texture. + /// </returns> + texture& operator=(const texture & _Other) + { + if (this != &_Other) + { + _M_extent = _Other._M_extent; + _M_texture_descriptor._Set_view_mipmap_levels(_Other.get_mipmap_levels()); + _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view, _Other); + } + return *this; + } + + /// <summary> + /// Move assignment operator + /// </summary> + /// <param name="_Other"> + /// The source texture to move from. + /// </param> + /// <returns> + /// A reference to this texture. + /// </returns> + texture& operator=(texture<_Value_type, _Rank> && _Other) + { + if (this != &_Other) + { + _M_extent = _Other._M_extent; + _M_texture_descriptor = _Other._M_texture_descriptor; + + _Other._M_texture_descriptor._M_data_ptr = NULL; + _Other._M_texture_descriptor._Set_texture_ptr(NULL); + } + return *this; + } + + /// <summary> + /// Copy-to, deep copy + /// </summary> + /// <param name="_Dest"> + /// The destination texture to copy to. + /// </param> + void copy_to(texture & _Dest) const + { + if (this->extent != _Dest.extent) + { + throw runtime_exception("The source and destination textures must have the exactly the same extent.", E_INVALIDARG); + } + + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(*this), + concurrency::details::_Get_texture_descriptor(_Dest), + this->get_data_length()); + + _Texture_base::_Copy_to(_Dest); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Copy-to, deep copy + /// </summary> + /// <param name="_Dest"> + /// The destination writeonly_texture_view to copy to. + /// </param> +#pragma warning( push ) +#pragma warning( disable : 4996 ) //writeonly_texture_view is deprecated + void copy_to(const writeonly_texture_view<_Value_type, _Rank> & _Dest) const + { + if (this->extent != _Dest.extent) + { + throw runtime_exception("The source and destination textures must have the exactly the same extent.", E_INVALIDARG); + } + + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(*this), + concurrency::details::_Get_texture_descriptor(_Dest), + this->get_data_length()); + + _Texture_base::_Copy_to(_Dest); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + /// <summary> + /// Destructor + /// </summary> + ~texture() __CPU_ONLY + { + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type operator[] (const index<_Rank>& _Index) const __GPU_ONLY + { + value_type _Tmp; + _Texture_read_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Index, /*_Mip_level=*/0); + return _Tmp; + } + + /// <summary> + /// Get the element value indexed by _I. + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I. + /// </returns> + const value_type operator[] (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "value_type texture::operator[](int) is only permissible on texture<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type operator() (const index<_Rank>& _Index) const __GPU_ONLY + { + return (*this)[_Index]; + } + + /// <summary> + /// Get the element value indexed by _I0 + /// </summary> + /// <param name="_I0"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I0. + /// </returns> + const value_type operator() (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "value_type texture::operator()(int) is only permissible on texture<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + const value_type operator() (int _I0, int _I1) const __GPU_ONLY + { + static_assert(_Rank == 2, "value_type texture::operator()(int, int) is only permissible on texture<value_type, 2>."); + return (*this)[index<2>(_I0, _I1)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + const value_type operator() (int _I0, int _I1, int _I2) const __GPU_ONLY + { + static_assert(_Rank == 3, "value_type texture::operator()(int, int, int) is only permissible on texture<value_type, 3>."); + return (*this)[index<3>(_I0, _I1, _I2)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type get(const index<_Rank>& _Index) const __GPU_ONLY + { + return (*this)[_Index]; + } + + /// <summary> + /// Set the element indexed by _Index with value _Value. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <param name="_Value"> + /// The value to be set to the element indexed by _Index. + /// </param> + void set(const index<_Rank>& _Index, const value_type& _Value) __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Num_channels == 1, "Invalid value_type for set method."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "Invalid value_type for set method."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "Invalid value_type for set method."); + _Texture_write_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Value, _Index); + } + + /// <summary> + /// Returns a CPU pointer to the raw data of this texture. + /// </summary> + _Ret_ void* data() __CPU_ONLY + { + return _Get_texture()->_Get_host_ptr(); + } + + /// <summary> + /// Returns a CPU pointer to the raw data of this texture. + /// </summary> + const void* data() const __CPU_ONLY + { + return _Get_texture()->_Get_host_ptr(); + } + + /// <summary> + /// Returns the row pitch (in bytes) of a 2D or 3D staging texture on the CPU to be + /// used for navigating the staging texture from row to row on the CPU. + /// </summary> + __declspec(property(get=get_row_pitch)) unsigned int row_pitch; + unsigned int get_row_pitch() const __CPU_ONLY + { + static_assert(_Rank >= 2, "row_pitch is only applicable to staging textures with rank 2 or higher."); + + if (!_Get_texture()->_Is_staging()) { + throw runtime_exception("row_pitch is only applicable to staging textures.", E_INVALIDARG); + } + + return static_cast<unsigned int>(_Get_texture()->_Get_row_pitch()); + } + + /// <summary> + /// Returns the depth pitch (in bytes) of a 3D staging texture on the CPU to be used + /// for navigating the staging texture from depth slice to depth slice on the CPU. + /// </summary> + __declspec(property(get=get_depth_pitch)) unsigned int depth_pitch; + unsigned int get_depth_pitch() const __CPU_ONLY + { + static_assert(_Rank == 3, "depth_pitch is only applicable to staging textures with rank 3."); + + if (!_Get_texture()->_Is_staging()) { + throw runtime_exception("depth_pitch is only applicable to staging textures.", E_INVALIDARG); + } + + return static_cast<unsigned int>(_Get_texture()->_Get_depth_pitch()); + } + + /// <summary> + /// Returns the accelerator_view that is the preferred target where this texture can be copied. + /// </summary> + __declspec(property(get=get_associated_accelerator_view)) Concurrency::accelerator_view associated_accelerator_view; + Concurrency::accelerator_view get_associated_accelerator_view() const __CPU_ONLY + { + return _Get_texture()->_Get_accelerator_view(); + } + +private: + // Private constructor used by make_texture to create a texture from D3D texture + texture(const Concurrency::extent<_Rank> & _Ext, const _Texture_descriptor & _Descriptor) + : details::_Texture_base<_Value_type, _Rank>(_Ext, _Descriptor) + { + } + + bool _Should_create_staging_texture(const Concurrency::accelerator_view &_Av, const Concurrency::accelerator_view &_Associated_av) + { + return (_Is_cpu_accelerator(_Av.accelerator) && !_Is_cpu_accelerator(_Associated_av.accelerator)); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av, unsigned int _Bits_per_scalar_element) __CPU_ONLY + { + if (_Bits_per_scalar_element != 8 && _Bits_per_scalar_element != 16 && + _Bits_per_scalar_element != 32 && _Bits_per_scalar_element != 64) + { + throw runtime_exception("Invalid _Bits_per_scalar_element argument - it can only be 8, 16, 32, or 64.", E_INVALIDARG); + } + + // special cases for 64 and for double based textures + +#pragma warning( push ) +#pragma warning( disable : 4127 ) // conditional expression is constant + if (_Bits_per_scalar_element == 64 && _Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Double_type) + { + throw runtime_exception("Invalid _Bits_per_scalar_element argument - 64 is only valid for texture of double based short vector types.", E_INVALIDARG); + } + + if (_Bits_per_scalar_element != 64 && _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type) + { + throw runtime_exception("Invalid _Bits_per_scalar_element argument - it can only be 64 for texture of double based short vector types.", E_INVALIDARG); + } + + details::_Is_valid_data_length(_M_extent.size(), _Bits_per_scalar_element * _Short_vector_type_traits<_Value_type>::_Num_channels); + + // the rest of the check is done by _Texture::_Create_texture, it depends on the underlying supported DXGI formats. + + unsigned int _Bits_per_channel = _Bits_per_scalar_element; + + if (_Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type) + { + _Bits_per_channel = _Short_vector_type_traits<_Value_type>::_Default_bits_per_channel; + } + + std::array<size_t, 3> _Dimensions = Concurrency::graphics::details::_Get_dimensions(_M_extent, /*_Mip_offset=*/0); + + // release the old texture first before allocating new one to avoid the chance on hitting OOM + _M_texture_descriptor._Set_texture_ptr(NULL); + _Texture_ptr _Tex_ptr = NULL; + + // See if we need to allocate a staging texture + if (_Should_create_staging_texture(_Av, _Associated_av)) { + + if (_M_texture_descriptor._Get_view_mipmap_levels() > 1) + { + throw runtime_exception("Creating staging textures with mipmap levels > 1 is not supported", E_INVALIDARG); + } + + _Tex_ptr = _Texture::_Create_stage_texture( + _Associated_av, _Av, _Rank, _Dimensions[0], _Dimensions[1], _Dimensions[2], _M_texture_descriptor._Get_view_mipmap_levels(), + _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type ? _Uint_type : _Short_vector_type_traits<_Value_type>::_Format_base_type_id, + _Short_vector_type_traits<_Value_type>::_Num_channels, + _Bits_per_channel); + + // Now map the texture + _Tex_ptr->_Map_buffer(_Write_access, true /* _Wait */); + } + else { + _Tex_ptr = _Texture::_Create_texture(_Av, _Rank, _Dimensions[0], _Dimensions[1], _Dimensions[2], _M_texture_descriptor._Get_view_mipmap_levels(), + _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type ? _Uint_type : _Short_vector_type_traits<_Value_type>::_Format_base_type_id, + _Short_vector_type_traits<_Value_type>::_Num_channels, + _Bits_per_channel); + } + + _M_texture_descriptor._Set_texture_ptr(_Tex_ptr); +#pragma warning( pop ) + } + + void _Initialize(const Concurrency::accelerator_view& _Av, unsigned int _Bits_per_scalar_element) __CPU_ONLY + { + _Initialize(_Av, _Av, _Bits_per_scalar_element); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av) __CPU_ONLY + { + _Initialize(_Av, _Associated_av, Concurrency::graphics::details::_Get_default_bits_per_scalar_element<_Value_type>()); + } + + void _Initialize(const Concurrency::accelerator_view& _Av) __CPU_ONLY + { + _Initialize(_Av, _Av); + } + + template<typename _Input_iterator> + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + { + _Initialize(_Av, _Associated_av); + + auto _Span_id = Concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + Concurrency::details::_Get_texture_descriptor(*this), + this->get_data_length()); + + Concurrency::graphics::details::_Copy_async_impl(_Src_first, _Src_last, *this, index<_Rank>(), this->extent)._Get(); + + Concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + template<typename _Input_iterator> + void _Initialize(const Concurrency::accelerator_view& _Av, _Input_iterator _Src_first, _Input_iterator _Src_last) __CPU_ONLY + { + _Initialize(_Av, _Av, _Src_first, _Src_last); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + { + _Initialize(_Av, _Associated_av, _Bits_per_scalar_element); + Concurrency::graphics::copy(_Source, _Src_byte_size, *this); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const void * _Source, unsigned int _Src_byte_size, unsigned int _Bits_per_scalar_element) __CPU_ONLY + { + _Initialize(_Av, _Av, _Source, _Src_byte_size, _Bits_per_scalar_element); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av, const void * _Source, unsigned int _Src_byte_size) __CPU_ONLY + { + _Initialize(_Av, _Associated_av); + Concurrency::graphics::copy(_Source, _Src_byte_size, *this); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const void * _Source, unsigned int _Src_byte_size) __CPU_ONLY + { + _Initialize(_Av, _Av, _Source, _Src_byte_size); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const Concurrency::accelerator_view& _Associated_av, const details::_Texture_base<_Value_type, _Rank> & _Src) __CPU_ONLY + { + if (_Src.bits_per_scalar_element != 0) // _Src is not created via interop + { + _Initialize(_Av, _Associated_av, _Src.bits_per_scalar_element); + } + else // _Src is created via interop, create a new texture with the same properties as the existing one. + { + _Texture_ptr _New_tex; + if (_Should_create_staging_texture(_Av, _Associated_av)) + { + _New_tex = _Texture::_Clone_texture(concurrency::details::_Get_texture(_Src), _Associated_av, _Av); + } + else + { + _New_tex = _Texture::_Clone_texture(concurrency::details::_Get_texture(_Src), _Av, _Associated_av); + } + _M_texture_descriptor._Set_texture_ptr(_New_tex); + } + + auto _Span_id = Concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(Concurrency::details::_Get_texture_descriptor(_Src), + Concurrency::details::_Get_texture_descriptor(*this), + this->get_data_length()); + + Concurrency::graphics::details::_Copy_async_impl(_Src, index<_Rank>(), *this, index<_Rank>(), this->extent)._Get(); + + Concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); + } + + void _Initialize(const Concurrency::accelerator_view& _Av, const details::_Texture_base<_Value_type, _Rank> & _Src) __CPU_ONLY + { + _Initialize(_Av, _Av, _Src); + } +}; + +/// <summary> +/// A writeonly_texture_view provides writeonly access to a texture. +/// </summary> +/// <param name="_Value_type"> +/// The type of the elements in the texture aggregates. +/// </param> +/// <param name="_Rank"> +/// The _Rank of the corresponding extent domain. +/// </param> +#pragma warning( push ) +#pragma warning( disable : 4996 ) //writeonly_texture_view is deprecated +template <typename _Value_type, int _Rank> class __declspec(deprecated("writeonly_texture_view is deprecated. Please use texture_view instead.")) writeonly_texture_view : public details::_Texture_base<_Value_type, _Rank> +{ + static_assert(!std::is_const<_Value_type>::value, "const value type is not supported for writeonly_texture_view."); + +public: + /// <summary> + /// Construct a writeonly_texture_view of a texture _Src. + /// </summary> + /// <param name="_Src"> + /// The texture on which the writeonly view is created. + /// </param> + writeonly_texture_view(texture<_Value_type, _Rank>& _Src) __CPU_ONLY + : _Texture_base(_Src, /*_Most_detailed_mipmap_level=*/0, /*_View_mipmap_levels=*/1) + { + _Texture* _Tex = _Get_texture(); + if ((_Tex->_Get_num_channels() == 3) && (_Tex->_Get_bits_per_channel() == 32)) { + throw runtime_exception("writeonly_texture_view cannot be created from a 3-channel texture with 32 bits per scalar element.", E_INVALIDARG); + } + if (_Tex->_Is_staging()) { + throw runtime_exception("writeonly_texture_view cannot be created from a staging texture object.", E_INVALIDARG); + } + } + + /// <summary> + /// Construct a writeonly_texture_view of a texture _Src. + /// </summary> + /// <param name="_Src"> + /// The texture on which the writeonly view is created. + /// </param> + writeonly_texture_view(texture<_Value_type, _Rank>& _Src) __GPU_ONLY + : _Texture_base(_Src, /*_Flatten_mipmap_levels=*/true) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Num_channels == 1, "Invalid value_type for the constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "Invalid value_type for the constructor."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "Invalid value_type for the constructor."); + } + + /// <summary> + /// Construct a writeonly_texture_view from another writeonly_texture_view. Both are views of the same texture. + /// </summary> + /// <param name="_Src"> + /// The writeonly_texture_view from which the current view is created. + /// </param> + writeonly_texture_view(const writeonly_texture_view<_Value_type, _Rank>& _Src) __GPU + : _Texture_base(_Src) + { + } + + /// <summary> + /// Assignment operator. This writeonly_texture_view becomes a view of the same texture which _Other is a view of. + /// </summary> + /// <param name="_Other"> + /// The source writeonly_texture_view. + /// </param> + writeonly_texture_view<_Value_type, _Rank>& operator=(const writeonly_texture_view<_Value_type, _Rank>& _Other) __GPU + { + if (this != &_Other) + { + _M_extent = _Other._M_extent; + _M_texture_descriptor = _Other._M_texture_descriptor; + } + return *this; + } + + /// <summary> + /// Destructor + /// </summary> + ~writeonly_texture_view() __GPU + { + } + + /// <summary> + /// Set the element indexed by _Index with value _Value. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <param name="_Value"> + /// The value to be set to the element indexed by _Index. + /// </param> + void set(const index<_Rank>& _Index, const value_type& _Value) const __GPU_ONLY + { + _Texture_write_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Value, _Index); + } +}; +#pragma warning( pop ) + +/// <summary> +/// A texture_view provides read and write access to a texture. +/// Note that currently texture_view can only be used to read textures whose value type is int, unsigned int and float +/// with default 32 bit bpse. To read other texture formats, use texture_view<const _Value_type, _Rank>. +/// </summary> +/// <param name="_Value_type"> +/// The type of the elements in the texture aggregates. +/// </param> +/// <param name="_Rank"> +/// The _Rank of the corresponding extent domain. +/// </param> +template <typename _Value_type, int _Rank> class texture_view : public details::_Texture_base<_Value_type, _Rank> +{ + friend class texture_view<const _Value_type, _Rank>; + +public: + /// <summary> + /// Construct a texture_view of a texture _Src on host. + /// </summary> + /// <param name="_Src"> + /// The texture on which the texture_view is created. + /// </param> + /// <param name="_Mipmap_level"> + /// The specific mipmap level on a _Src texture that this read and write texture_view should bind to. + /// The default value 0, binds to the top mosted detail mipmap level. + /// </param> + texture_view(texture<_Value_type, _Rank>& _Src, unsigned int _Mipmap_level = 0) __CPU_ONLY + : _Texture_base(_Src, _Mipmap_level, /*_View_mipmap_levels=*/1) + { + if (_Get_texture()->_Is_staging()) { + throw runtime_exception("texture_view cannot be created from a staging texture object.", E_INVALIDARG); + } + } + + /// <summary> + /// Construct a texture_view of a texture _Src on an accelerator. + /// </summary> + /// <param name="_Src"> + /// The texture on which the texture_view is created. + /// </param> + texture_view(texture<_Value_type, _Rank>& _Src) __GPU_ONLY + : _Texture_base(_Src, /*_Flatten_mipmap_levels=*/true) + { + static_assert(_Short_vector_type_traits<_Value_type>::_Num_channels == 1, "writable texture_view can only be created from a single-component texture on an accelerator."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "writable texture_view cannot be created from a unorm texture on an accelerator."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "writable texture_view cannot be created from a norm texture on an accelerator."); + } + + /// <summary> + /// Construct a texture_view from another texture_view. Both are views of the same texture. + /// </summary> + /// <param name="_Other"> + /// The source texture_view. + /// </param> + texture_view(const texture_view<_Value_type, _Rank>& _Other) __GPU + : _Texture_base(_Other) + { + } + + /// <summary> + /// Assignment operator. This texture_view becomes a view of the same texture which _Other is a view of. + /// </summary> + /// <param name="_Other"> + /// The source texture_view. + /// </param> + texture_view<_Value_type, _Rank>& operator=(const texture_view<_Value_type, _Rank>& _Other) __GPU + { + if (this != &_Other) + { + _M_extent = _Other._M_extent; + _M_texture_descriptor = _Other._M_texture_descriptor; + } + return *this; + } + + /// <summary> + /// Destructor + /// </summary> + ~texture_view() __GPU + { + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type operator[] (const index<_Rank>& _Index) const __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Num_channels == 1, "Read is only permissible on single-component writable texture_view."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Unorm_type, "Read is not permissible on a writable unorm texture_view."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Norm_type, "Read is not permissible on a writable norm texture_view."); + + value_type _Tmp; + _Texture_read_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Index, /*_Mip_level=*/0); + return _Tmp; + } + + /// <summary> + /// Get the element value indexed by _I0. + /// </summary> + /// <param name="_I0"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I0. + /// </returns> + const value_type operator[] (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "const value_type operator[](int) is only permissible on texture_view<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type operator() (const index<_Rank>& _Index) const __GPU_ONLY + { + return (*this)[_Index]; + } + + /// <summary> + /// Get the element value indexed by _I0 + /// </summary> + /// <param name="_I0"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I0. + /// </returns> + const value_type operator() (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "const value_type operator()(int) is only permissible on texture_view<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + const value_type operator() (int _I0, int _I1) const __GPU_ONLY + { + static_assert(_Rank == 2, "const value_type operator()(int, int) is only permissible on texture_view<value_type, 2>."); + return (*this)[index<2>(_I0, _I1)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + const value_type operator() (int _I0, int _I1, int _I2) const __GPU_ONLY + { + static_assert(_Rank == 3, "const value_type operator()(int, int, int) is only permissible on texture_view<value_type, 3>."); + return (*this)[index<3>(_I0, _I1, _I2)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + const value_type get(const index<_Rank>& _Index) const __GPU_ONLY + { + return (*this)[_Index]; + } + + /// <summary> + /// Set the element indexed by _Index with value _Value. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <param name="_Value"> + /// The value to be set to the element indexed by _Index. + /// </param> + void set(const index<_Rank>& _Index, const value_type& _Value) const __GPU_ONLY + { + _Texture_write_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Value, _Index); + } +}; + +/// <summary> +/// filter modes supported for texture sampling +/// </summary> +enum filter_mode +{ + filter_point = 0, + filter_linear = 0x15, + filter_unknown = 0xFFFFFFFF, +}; + +/// <summary> +/// address modes supported for texture sampling +/// </summary> +enum address_mode +{ + address_wrap = 1, + address_mirror = 2, + address_clamp = 3, + address_border = 4, + address_unknown = 0xFFFFFFFF, +}; + +/// <summary> +/// A sampler class aggregates sampling configuration information to be used for texture sampling. +/// </summary> +class sampler +{ + friend sampler direct3d::make_sampler(_In_ IUnknown *_D3D_sampler) __CPU_ONLY; + friend _Ret_ IUnknown * direct3d::get_sampler(const Concurrency::accelerator_view &_Av, const sampler &_Sampler) __CPU_ONLY; + + template <typename _Value_type, int _Rank> + friend class texture_view; + +public: + /// <summary> + /// Constructs a sampler with default filter mode (filter_lienar, same for min, mag, mip), addressing + /// mode (address_clamp, same for all dimensions), and border color (float_4(0.0f, 0.0f, 0.0f, 0.0f)). + /// </summary> + sampler() __CPU_ONLY + : _M_filter_mode(filter_linear), + _M_address_mode(address_clamp), + _M_border_color(float_4(0.0f, 0.0f, 0.0f, 0.0f)) + { + _Initialize(); + } + + /// <summary> + /// Constructs a sampler with specified filter mode (same for min, mag, mip), but with default addressing + /// mode (address_clamp, same for all dimensions) and border color ( float_4(0.0f, 0.0f, 0.0f, 0.0f)). + /// </summary> + /// <param name="_Filter_mode"> + /// The filter mode to be used in sampling. + /// </param> + sampler(filter_mode _Filter_mode)__CPU_ONLY + : _M_filter_mode(_Filter_mode), + _M_address_mode(address_clamp), + _M_border_color(float_4(0.0f, 0.0f, 0.0f, 0.0f)) + { + _Initialize(); + } + + /// <summary> + /// Constructs a sampler with default filter mode (filter_linear, same for min, mag, mip), but specified + /// addressing mode (same for all dimensions) and border color. + /// </summary> + /// <param name="_Address_mode"> + /// The addressing mode to be used in sampling for all dimensions. + /// </param> + /// <param name="_Border_color"> + /// The border color to be used if address mode is address_border. If not specified, default value is float_4(0.f, 0.f, 0.f, 0.f). + /// </param> + sampler(address_mode _Address_mode, float_4 _Border_color = float_4(0.0f, 0.0f, 0.0f, 0.0f)) __CPU_ONLY + : _M_filter_mode(filter_linear), + _M_address_mode(_Address_mode), + _M_border_color(_Border_color) + { + _Initialize(); + } + + /// <summary> + /// Constructs a sampler with specified filter mode (same for min, mag, mip), addressing + /// mode (same for all dimensions) and the border color. + /// </summary> + /// <param name="_Filter_mode"> + /// The filter mode to be used in sampling. + /// </param> + /// <param name="_Address_mode"> + /// The addressing mode to be used in sampling for all dimensions. + /// </param> + /// <param name="_Border_color"> + /// The border color to be used if address mode is address_border. If not specified, default value is float_4(0.f, 0.f, 0.f, 0.f). + /// </param> + sampler(filter_mode _Filter_mode, address_mode _Address_mode, float_4 _Border_color = float_4(0.0f, 0.0f, 0.0f, 0.0f)) __CPU_ONLY + : _M_filter_mode(_Filter_mode), + _M_address_mode(_Address_mode), + _M_border_color(_Border_color) + { + _Initialize(); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// An object of type sampler from which to initialize this new sampler. + /// </param> + sampler(const sampler& _Other) __GPU + : _M_filter_mode(_Other._M_filter_mode), + _M_address_mode(_Other._M_address_mode), + _M_border_color(_Other._M_border_color), + _M_sampler_descriptor(_Other._M_sampler_descriptor) + { + } + + /// <summary> + /// Move constructor. + /// </summary> + /// <param name="_Other"> + /// The sampler to move from. + /// </param> + sampler(sampler &&_Other) __GPU + : _M_filter_mode(_Other._M_filter_mode), + _M_address_mode(_Other._M_address_mode), + _M_border_color(_Other._M_border_color), + _M_sampler_descriptor(_Other._M_sampler_descriptor) + { + _Other._M_sampler_descriptor._M_data_ptr = NULL; + _Other._M_sampler_descriptor._Set_sampler_ptr(NULL); + } + + /// <summary> + /// Assignment operator. + /// </summary> + /// <param name="_Other"> + /// An object of type sampler from which to copy into this sampler. + /// </param> + /// <returns> + /// A reference to this sampler. + /// </returns> + sampler& operator=(const sampler& _Other) __GPU + { + if (this != &_Other) + { + _M_filter_mode = _Other._M_filter_mode; + _M_address_mode = _Other._M_address_mode; + _M_border_color = _Other._M_border_color; + _M_sampler_descriptor = _Other._M_sampler_descriptor; + } + return *this; + } + + /// <summary> + /// Move assignment operator. + /// </summary> + /// <param name="_Other"> + /// An object of type sampler to move from. + /// </param> + /// <returns> + /// A reference to this sampler. + /// </returns> + sampler& operator=(sampler&& _Other) __GPU + { + if (this != &_Other) + { + _M_filter_mode = _Other._M_filter_mode; + _M_address_mode = _Other._M_address_mode; + _M_border_color = _Other._M_border_color; + _M_sampler_descriptor = _Other._M_sampler_descriptor; + _Other._M_sampler_descriptor._M_data_ptr = NULL; + _Other._M_sampler_descriptor._Set_sampler_ptr(NULL); + } + return *this; + } + + /// <summary> + /// Returns the sampler's filter mode + /// </summary> + __declspec(property(get=get_filter_mode)) Concurrency::graphics::filter_mode filter_mode; + Concurrency::graphics::filter_mode get_filter_mode() const __GPU + { + return _M_filter_mode; + } + + /// <summary> + /// Returns the sampler's address mode + /// </summary> + __declspec(property(get=get_address_mode)) Concurrency::graphics::address_mode address_mode; + Concurrency::graphics::address_mode get_address_mode() const __GPU + { + return _M_address_mode; + } + + /// <summary> + /// Returns the sampler's border value + /// </summary> + __declspec(property(get=get_border_color)) Concurrency::graphics::float_4 border_color; + Concurrency::graphics::float_4 get_border_color() const __GPU + { + return _M_border_color; + } + +private: + // internal storage abstraction + typedef Concurrency::details::_Sampler_descriptor _Sampler_descriptor; + + // a private constructor to be used for constructing a sampler via interop. + sampler(const _Sampler_descriptor & _Descriptor) __CPU_ONLY + : _M_sampler_descriptor(_Descriptor), + _M_filter_mode(filter_unknown), + _M_address_mode (address_unknown), + _M_border_color(float_4(0.0f, 0.0f, 0.0f, 0.0f)) + { + // Although we could query border value from the adopted sampler, but it's not that useful + // given that this is the only thing that we could query and when the address mode is not + // address_border, border value is not relevant. + } + + _Ret_ _Sampler* _Get_sampler_ptr() const __CPU_ONLY + { + return _M_sampler_descriptor._Get_sampler_ptr(); + } + + void _Initialize() __CPU_ONLY + { + // Check if the given filter_mode and address_mode are valid C++ AMP ones + if ((_M_filter_mode != filter_point && _M_filter_mode != filter_linear) || + (_M_address_mode != address_wrap && _M_address_mode != address_mirror && + _M_address_mode != address_clamp && _M_address_mode != address_border)) + { + throw runtime_exception("Invalid sampler configuration", E_INVALIDARG); + } + + _Sampler_ptr samplerPtr = _Sampler::_Create(_M_filter_mode, _M_address_mode, + _M_border_color.r, _M_border_color.g, _M_border_color.b, _M_border_color.a); + _M_sampler_descriptor._Set_sampler_ptr(samplerPtr); + } + + const _Sampler_descriptor & _Get_descriptor() const __GPU_ONLY + { + return _M_sampler_descriptor; + } + + _Sampler_descriptor _M_sampler_descriptor; + Concurrency::graphics::filter_mode _M_filter_mode; + Concurrency::graphics::address_mode _M_address_mode; + float_4 _M_border_color; +}; + +/// <summary> +/// A texture_view<const _Value_type, _Rank> provides read-only access and sampling capability to a texture. +/// </summary> +/// <param name="_Value_type"> +/// The type of the elements in the texture aggregates. +/// </param> +/// <param name="_Rank"> +/// The _Rank of the corresponding extent domain. +/// </param> +template <typename _Value_type, int _Rank> class texture_view<const _Value_type, _Rank> : public details::_Texture_base<_Value_type, _Rank> +{ +public: + typedef typename const _Value_type value_type; + typedef typename short_vector<float, _Rank>::type coordinates_type; + typedef typename short_vector<scalar_type, 4>::type gather_return_type; + + /// <summary> + /// Construct a read-only texture_view of a texture _Src on an accelerator. + /// </summary> + /// <param name="_Src"> + /// The texture on which the read-only view is created. + /// </param> + texture_view(const texture<_Value_type, _Rank>& _Src) __GPU_ONLY + : _Texture_base(_Src) + { + // only on the gpu it is not allowed + static_assert(_Short_vector_type_traits<_Value_type>::_Num_channels != 1, "Read-only texture_view cannot be created from single-component textures on an accelerator."); + } + + /// <summary> + /// Construct a texture_view of a texture _Src on the host. + /// </summary> + /// <param name="_Src"> + /// The texture on which the read-only view is created. + /// </param> + texture_view(const texture<_Value_type, _Rank>& _Src) __CPU_ONLY + : _Texture_base(_Src) + { + if (_Get_texture()->_Is_staging()) { + throw runtime_exception("Read-only texture_view cannot be created from a staging texture object.", E_INVALIDARG); + } + } + + /// <summary> + /// Construct a read-only texture_view with specific range of mipmap levels of a texture _Src on the host. + /// </summary> + /// <param name="_Src"> + /// The texture on which the read-only view is created. + /// </param> + /// <param name="_Most_detailed_mip"> + /// Most detailed mipmap level for the view. + /// </param> + /// <param name="_Mip_levels"> + /// The number of mipmap levels accessible for the view. + /// </param> + texture_view(const texture<_Value_type, _Rank>& _Src, unsigned int _Most_detailed_mip, unsigned int _Mip_levels) __CPU_ONLY + : _Texture_base(_Src, _Most_detailed_mip, _Mip_levels) + { + if (_Get_texture()->_Is_staging()) { + throw runtime_exception("Read-only texture_view cannot be created from a staging texture object.", E_INVALIDARG); + } + } + + /// <summary> + /// Construct a read-only texture_view of a writable texture_view. + /// </summary> + /// <param name="_Other"> + /// The writable texture view from which the read-only view is created. + /// </param> + texture_view(const texture_view<_Value_type, _Rank>& _Other) __CPU_ONLY + : _Texture_base(_Other) + { + } + + /// <summary> + /// Construct a read-only texture_view from another read-only texture_view. Both are views of the same texture. + /// </summary> + /// <param name="_Other"> + /// The source read-only texture_view. + /// </param> + texture_view(const texture_view<const _Value_type, _Rank>& _Other) __GPU + : _Texture_base(_Other) + { + } + + /// <summary> + /// Construct a read-only texture_view from another read-only texture_view. + /// Allows narrowing down the accessible range of mipmap levels for the texture_view. + /// Both are views of the same texture. + /// </summary> + /// <param name="_Other"> + /// The source read-only texture_view. + /// </param> + /// <param name="_Most_detailed_mip"> + /// Top level mipmap for the view, relative to the input texture_view. + /// </param> + /// <param name="_Mip_levels"> + /// The number of mipmap levels accessible for the view. + /// </param> + texture_view(const texture_view<const _Value_type, _Rank>& _Other, unsigned int _Most_detailed_mip, unsigned int _Mip_levels) __CPU_ONLY + : _Texture_base(_Other, _Most_detailed_mip, _Mip_levels) + { + } + + /// <summary> + /// Assignment operator. This read-only texture_view becomes a view of the same texture which _Other is a view of. + /// </summary> + /// <param name="_Other"> + /// The source read-only texture_view. + /// </param> + texture_view<const _Value_type, _Rank>& operator=(const texture_view<const _Value_type, _Rank>& _Other) __GPU + { + if (this != &_Other) + { + _M_extent = _Other._M_extent; + _M_texture_descriptor = _Other._M_texture_descriptor; + } + return *this; + } + + /// <summary> + /// Assignment operator from a writable texture_view. + /// This read-only texture_view becomes a view of the same texture which _Other is a view of. + /// </summary> + /// <param name="_Other"> + /// The source writable texture_view. + /// </param> + texture_view<const _Value_type, _Rank>& operator=(const texture_view<_Value_type, _Rank>& _Other) __CPU_ONLY + { + _M_extent = _Other._M_extent; + _M_texture_descriptor = _Other._M_texture_descriptor; + return *this; + } + + /// <summary> + /// Destructor + /// </summary> + ~texture_view() __GPU + { + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + value_type operator[] (const index<_Rank>& _Index) const __GPU_ONLY + { + _Value_type _Tmp; + _Texture_read_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Index, /*_Mip_level=*/0); + return _Tmp; + } + + /// <summary> + /// Get the element value indexed by _I. + /// </summary> + /// <param name="_I"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I. + /// </returns> + value_type operator[] (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "value_type operator[](int) is only permissible on texture_view<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + value_type operator() (const index<_Rank>& _Index) const __GPU_ONLY + { + return (*this)[_Index]; + } + + /// <summary> + /// Get the element value indexed by _I0 + /// </summary> + /// <param name="_I0"> + /// The index. + /// </param> + /// <returns> + /// The element value indexed by _I0. + /// </returns> + value_type operator() (int _I0) const __GPU_ONLY + { + static_assert(_Rank == 1, "value_type texture_view::operator()(int) is only permissible on texture_view<value_type, 1>."); + return (*this)[index<1>(_I0)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1) + /// </returns> + value_type operator() (int _I0, int _I1) const __GPU_ONLY + { + static_assert(_Rank == 2, "value_type texture_view::operator()(int, int) is only permissible on texture_view<value_type, 2>."); + return (*this)[index<2>(_I0, _I1)]; + } + + /// <summary> + /// Get the element value indexed by (_I0,_I1,_I2) + /// </summary> + /// <param name="_I0"> + /// The most-significant component of the index + /// </param> + /// <param name="_I1"> + /// The next-to-most-significant component of the index + /// </param> + /// <param name="_I2"> + /// The least-significant component of the index + /// </param> + /// <returns> + /// The element value indexed by (_I0,_I1,_I2) + /// </returns> + value_type operator() (int _I0, int _I1, int _I2) const __GPU_ONLY + { + static_assert(_Rank == 3, "value_type texture_view::operator()(int, int, int) is only permissible on texture_view<value_type, 3>."); + return (*this)[index<3>(_I0, _I1, _I2)]; + } + + /// <summary> + /// Get the element value indexed by _Index. + /// </summary> + /// <param name="_Index"> + /// The index. + /// </param> + /// <param name="_Mip_level"> + /// The mipmap level from which we should get indexed value. + /// The default value 0 represents most detailed mipmap level. + /// </param> + /// <returns> + /// The element value indexed by _Index. + /// </returns> + value_type get(const index<_Rank>& _Index, unsigned int _Mip_level = 0) const __GPU_ONLY + { + _Value_type _Tmp; + _Texture_read_helper<index<_Rank>, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Index, _Mip_level); + return _Tmp; + } + + /// <summary> + /// Sample the texture at the given coordinates and level of detail using the specified sampling configuration. + /// </summary> + /// <param name="_Sampler"> + /// The sampler that configures the sampling operation. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <param name="_Level_of_detail"> + /// The value specifies the mipmap level to sample from. + /// Fractional value is used to interpolate between two mipmap levels. + /// </param> + /// <returns> + /// The interpolated value. + /// </returns> + value_type sample(const sampler& _Sampler, const coordinates_type& _Coord, float _Level_of_detail = 0.0f) const __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Uint_type, "sample is not allowed for uint component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Int_type, "sample is not allowed for int component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Double_type, "sample is not allowed for double component types in the texture value_type."); + + _Value_type _Tmp; + _Texture_sample_helper<coordinates_type, _Rank>::func(_M_texture_descriptor._M_data_ptr, _Sampler._Get_descriptor()._M_data_ptr, &_Tmp, _Coord, 4 /*Sampling*/, _Level_of_detail); + return _Tmp; + } + + /// <summary> + /// Sample the texture at the given coordinates and level of detail using the predefined sampling configuration. + /// </summary> + /// <param name="_Filter_mode"> + /// The filter mode of the predefined sampler to be used. + /// </param> + /// <param name="_Address_mode"> + /// The address mode of the predefined sampler to be used. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <param name="_Level_of_detail"> + /// The value specifies the mipmap level to sample from. + /// Fractional value is used to interpolate between two mipmap levels. + /// </param> + /// <returns> + /// The interpolated value. + /// </returns> + template<filter_mode _Filter_mode = filter_linear, address_mode _Address_mode = address_clamp> + value_type sample(const coordinates_type& _Coord, float _Level_of_detail = 0.0f) const __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Uint_type, "sample is not allowed for uint component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Int_type, "sample is not allowed for int component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Double_type, "sample is not allowed for double component types in the texture value_type."); + static_assert((_Filter_mode == filter_point || _Filter_mode == filter_linear), "Invalid filter mode for sample method."); + static_assert((_Address_mode == address_wrap || _Address_mode == address_clamp || _Address_mode == address_mirror || _Address_mode == address_border), + "Invalid address mode for sample method."); + + _Value_type _Tmp; + // Predefined sampler id is constructed as filter_mode << 16 | address_mode. This is a contract between BE and runtime. Modify with caution! + _Texture_predefined_sample_helper<coordinates_type, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Coord, _Filter_mode << 16 |_Address_mode, 4 /*Sampling*/, _Level_of_detail); + return _Tmp; + } + + /// <summary> + /// Sample the texture at the given coordinates using the specified sampling configuration and return the red (x) component of the four texels samples. + /// </summary> + /// <param name="_Sampler"> + /// The sampler that configures the sampling operation. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the red (x) component of the 4 texel values sampled. + /// </returns> + const gather_return_type gather_red(const sampler& _Sampler, const coordinates_type& _Coord) const __GPU_ONLY + { + return _Gather(_Sampler, _Coord, 0); + } + + /// <summary> + /// Sample the texture at the given coordinates using the specified sampling configuration and return the green (y) component of the four texels samples. + /// </summary> + /// <param name="_Sampler"> + /// The sampler that configures the sampling operation. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the green (y) component of the 4 texel values sampled. + /// </returns> + const gather_return_type gather_green(const sampler& _Sampler, const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(1 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_green is valid only for textures with 2 or more components in the value_type."); + + return _Gather(_Sampler, _Coord, 1); + } + + /// <summary> + /// Sample the texture at the given coordinates using the specified sampling configuration and return the blue (z) component of the four texels samples. + /// </summary> + /// <param name="_Sampler"> + /// The sampler that configures the sampling operation. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the blue (z) component of the 4 texel values sampled. + /// </returns> + const gather_return_type gather_blue(const sampler& _Sampler, const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(2 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_blue is valid only for textures with 3 or more components in the value_type."); + + return _Gather(_Sampler, _Coord, 2); + } + + /// <summary> + /// Sample the texture at the given coordinates using the specified sampling configuration and return the alpha (w) component of the four texels samples. + /// </summary> + /// <param name="_Sampler"> + /// The sampler that configures the sampling operation. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the alpha (w) component of the 4 texel values sampled. + /// </returns> + const gather_return_type gather_alpha(const sampler& _Sampler, const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(3 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_alpha is valid only for textures with 4 components in the value_type."); + + return _Gather(_Sampler, _Coord, 3); + } + + /// <summary> + /// Sample the texture at the given coordinates using the predefined sampling configuration and return the red (x) component of the four texels samples. + /// </summary> + /// <param name="_Address_mode"> + /// The address mode of the predefined sampler to be used. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the red (x) component of the 4 texel values sampled. + /// </returns> + template<address_mode _Address_mode = address_clamp> + const gather_return_type gather_red(const coordinates_type& _Coord) const __GPU_ONLY + { + return _Gather<_Address_mode>(_Coord, 0); + } + + /// <summary> + /// Sample the texture at the given coordinates using the predefined sampling configuration and return the green (y) component of the four texels samples. + /// </summary> + /// <param name="_Address_mode"> + /// The address mode of the predefined sampler to be used. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the green (y)component of the 4 texel values sampled. + /// </returns> + template<address_mode _Address_mode = address_clamp> + const gather_return_type gather_green(const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(1 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_green is valid only for textures with 2 or more components in the value_type."); + + return _Gather<_Address_mode>(_Coord, 1); + } + + /// <summary> + /// Sample the texture at the given coordinates using the predefined sampling configuration and return the blue (z) component of the four texels samples. + /// </summary> + /// <param name="_Address_mode"> + /// The address mode of the predefined sampler to be used. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the blue (z) component of the 4 texel values sampled. + /// </returns> + template<address_mode _Address_mode = address_clamp> + const gather_return_type gather_blue(const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(2 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_blue is valid only for textures with 3 or more components in the value_type."); + + return _Gather<_Address_mode>(_Coord, 2); + } + + /// <summary> + /// Sample the texture at the given coordinates using the predefined sampling configuration and return the alpha (w) component of the four texels samples. + /// </summary> + /// <param name="_Address_mode"> + /// The address mode of the predefined sampler to be used. + /// </param> + /// <param name="_Coord"> + /// Coordinate vector for sampling. + /// </param> + /// <returns> + /// Rank 4 short vector containing the alpha (w) component of the 4 texel values sampled. + /// </returns> + template<address_mode _Address_mode = address_clamp> + const gather_return_type gather_alpha(const coordinates_type& _Coord) const __GPU_ONLY + { + static_assert(3 < _Short_vector_type_traits<_Value_type>::_Num_channels, "gather_alpha is valid only for textures with 4 components in the value_type."); + + return _Gather<_Address_mode>(_Coord, 3); + } + +private: + const gather_return_type _Gather(const sampler& _Sampler, const coordinates_type& _Coord, unsigned int _Component) const __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Uint_type, "gather is not allowed for uint component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Int_type, "gather is not allowed for int component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Double_type, "gather is not allowed for double component types in the texture value_type."); + static_assert(rank == 2, "gather methods are only permissible on texture_view<value_type, 2>."); + + gather_return_type _Tmp; + _Texture_sample_helper<coordinates_type, _Rank>::func(_M_texture_descriptor._M_data_ptr, _Sampler._Get_descriptor()._M_data_ptr, &_Tmp, _Coord, _Component, /*_Level_of_detail=*/0.0f); + return _Tmp; + } + + template<address_mode _Address_mode> + const gather_return_type _Gather(const coordinates_type& _Coord, unsigned int _Component) const __GPU_ONLY + { + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Uint_type, "gather is not allowed for uint component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Int_type, "gather is not allowed for int component types in the texture value_type."); + static_assert(_Short_vector_type_traits<_Value_type>::_Format_base_type_id != _Double_type, "gather is not allowed for double component types in the texture value_type."); + static_assert(rank == 2, "gather methods are only permissible on texture_view<value_type, 2>."); + static_assert((_Address_mode == address_wrap || _Address_mode == address_clamp || _Address_mode == address_mirror || _Address_mode == address_border), + "Invalid address mode for gather methods."); + + gather_return_type _Tmp; + // Predefined sampler id is constructed as filter_mode << 16 | address_mode. This is a contract between BE and runtime. Modify with caution! + // gather only used the address_mode of the sampler, internally we use filter_point so that the predefined sampler id scheme is same for both sample and gather. + _Texture_predefined_sample_helper<coordinates_type, _Rank>::func(_M_texture_descriptor._M_data_ptr, &_Tmp, _Coord, filter_point << 16 |_Address_mode, _Component, /*_Level_of_detail=*/0.0f); + return _Tmp; + } +}; + +namespace details +{ + +template <typename T> +struct texture_traits +{ + static const bool is_texture = false; + static const bool is_writable = false; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<texture<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = true; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<const texture<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = false; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<writeonly_texture_view<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = true; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<const writeonly_texture_view<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = true; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<texture_view<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = true; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<texture_view<const _Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = false; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<const texture_view<const _Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = false; +}; + +template <typename _Value_type, int _Rank> +struct texture_traits<const texture_view<_Value_type, _Rank>> +{ + static const bool is_texture = true; + static const bool is_writable = true; +}; + +// The helper function used by ETW and copy functions to calculate number of bytes for the copy operation given input section +template <typename _Value_type, int _Rank> +unsigned int _Get_section_size(const _Texture_base<_Value_type, _Rank> &_Tex, const extent<_Rank> &_Extent) +{ + _Texture* _Tex_ptr = _Get_texture(_Tex); + _Texture_descriptor _Tex_desc = _Get_texture_descriptor(_Tex); + + return _Tex_ptr->_Get_data_length(_Tex_desc._Get_most_detailed_mipmap_level(), _Tex_desc._Get_view_mipmap_levels(), _Get_dimensions(_Extent, /*Mip_offset=*/0).data()); +} + +template <typename _Input_iterator, typename _Value_type> +_Event _Copy_async_impl(_Input_iterator _First, _Input_iterator _Last, + _In_ _Texture *_Dst, const size_t *_Dst_offset, unsigned int _Dst_mipmap_level, + const size_t *_Copy_extent, const size_t *_Preferred_copy_chunk_extent = NULL) +{ + _ASSERTE(_Dst != nullptr); + _ASSERTE(_Dst_offset != nullptr); + _ASSERTE(_Copy_extent != nullptr); + + _ASSERTE((unsigned int)std::distance(_First, _Last) >= (_Copy_extent[0] * _Copy_extent[1] * _Copy_extent[2])); + + // The copy region should be within the bounds of the destination texture + _ASSERTE((_Dst_offset[0] + _Copy_extent[0]) <= _Dst->_Get_width(_Dst_mipmap_level)); + _ASSERTE((_Dst_offset[1] + _Copy_extent[1]) <= _Dst->_Get_height(_Dst_mipmap_level)); + _ASSERTE((_Dst_offset[2] + _Copy_extent[2]) <= _Dst->_Get_depth(_Dst_mipmap_level)); + +#pragma warning( push ) +#pragma warning( disable : 4127 ) // conditional expression is constant + if ((sizeof(_Value_type) > sizeof(unsigned char)) && (_Dst->_Get_bits_per_element() != (8U * sizeof(_Value_type)))) + { + throw runtime_exception("Iterator-based copy is not supported on textures where the size of the _Value_type is not equal to the texel size.", E_INVALIDARG); + } +#pragma warning( pop ) + + // If the dest is accessible on the host we can perform the copy entirely on the host + if (_Dst->_Get_host_ptr() != NULL) + { + // We have made sure that the three multiplications below won't cause integer overflow when creating the texture + _ASSERTE(((_Dst->_Get_bits_per_element() * _Copy_extent[0]) % (8U * sizeof(_Value_type))) == 0); + + size_t _Row_size = (_Dst->_Get_bits_per_element() * _Copy_extent[0]) >> 3; // in bytes + size_t _Depth_slice_size = _Row_size * _Copy_extent[1]; + + size_t _Row_pitch = _Dst->_Get_row_pitch(); + size_t _Depth_pitch = _Dst->_Get_depth_pitch(); + _ASSERTE(_Row_pitch >= _Row_size); + _ASSERTE(_Depth_pitch >= _Depth_slice_size); + + size_t _Dst_offset_in_bytes = ((_Dst_offset[0] * _Dst->_Get_bits_per_element()) >> 3) + + (_Dst_offset[1] * _Row_pitch) + (_Dst_offset[2] * _Depth_pitch); + + unsigned char *_PDest = reinterpret_cast<unsigned char*>(_Dst->_Get_host_ptr()) + _Dst_offset_in_bytes; + + _Copy_data_on_host(_Dst->_Get_rank(), _First, reinterpret_cast<_Value_type*>(_PDest), + _Row_size / sizeof(_Value_type), _Copy_extent[1], _Copy_extent[2], + _Row_pitch, _Depth_pitch, _Row_size / sizeof(_Value_type), _Depth_slice_size / sizeof(_Value_type)); + + return _Event(); + } + + // The dest is not accessbile on the host; we need to copy src to + // a temporary staging texture and launch a copy from the staging texture + // to the dest texture. + _Event _Ev; + + // Determine the copy chunk extent + std::array<size_t, 3> _Copy_chunk_extent; + if (_Preferred_copy_chunk_extent != NULL) + { + std::copy(&_Preferred_copy_chunk_extent[0], &_Preferred_copy_chunk_extent[3], _Copy_chunk_extent.begin()); + } + else + { + _Get_preferred_copy_chunk_extent(_Dst->_Get_rank(), _Copy_extent[0], _Copy_extent[1], _Copy_extent[2], _Dst->_Get_bits_per_element(), _Copy_chunk_extent.data()); + } + + std::array<size_t, 3> _Curr_copy_offset; + std::copy(&_Dst_offset[0], &_Dst_offset[3], _Curr_copy_offset.begin()); + + std::array<size_t, 3> _Remaining_copy_extent; + std::copy(&_Copy_extent[0], &_Copy_extent[3], _Remaining_copy_extent.begin()); + + bool _Truncated_copy = false; + do + { + _Texture_ptr _Dst_staging_tex_ptr; + std::array<size_t, 3> _Curr_copy_extent; + _Truncated_copy = _Get_chunked_staging_texture(_Dst, _Copy_chunk_extent.data(), _Remaining_copy_extent.data(), _Curr_copy_extent.data(), &_Dst_staging_tex_ptr); + + + // Now copy from the src pointer to the temp staging texture + _Dst_staging_tex_ptr->_Map_buffer(_Write_access, true /* _Wait */); + + std::array<size_t, 3> _Dst_staging_tex_offset; + _Dst_staging_tex_offset.fill(0); + _Event _Temp_ev = _Copy_async_impl<_Input_iterator, _Value_type>(_First, _Last, _Dst_staging_tex_ptr, + _Dst_staging_tex_offset.data(), /*_Dst_mipmap_level=*/0, _Curr_copy_extent.data(), _Copy_chunk_extent.data()); + + // Now chain a copy from the temporary staging texture to the _Dst texture + _Texture_ptr _Dst_tex_ptr = _Dst; + _Temp_ev = _Temp_ev._Add_continuation(std::function<_Event()>([_Dst_staging_tex_ptr, _Dst_tex_ptr, _Curr_copy_extent, + _Dst_staging_tex_offset, _Curr_copy_offset, _Dst_mipmap_level]() mutable -> _Event + { + return _Dst_staging_tex_ptr->_Copy_to_async(_Dst_tex_ptr, _Curr_copy_extent.data(), _Dst_staging_tex_offset.data(), _Curr_copy_offset.data(), /*_Src_mipmap_level=*/0, _Dst_mipmap_level); + })); + + _Ev = _Ev._Add_event(_Temp_ev); + + // Now adjust the _Src and _Dst offsets for the remaining part of the copy + if (_Truncated_copy) + { + // The offset only needs to be adjusted in the most significant dimension + _Curr_copy_offset[_Dst->_Get_rank() - 1] += _Curr_copy_extent[_Dst->_Get_rank() - 1]; + std::advance(_First, (((_Curr_copy_extent[0] * _Dst->_Get_bits_per_element()) >> 3) / sizeof(_Value_type)) * _Curr_copy_extent[1] * _Curr_copy_extent[2]); + } + + } while (_Truncated_copy); + + return _Ev; +} + +template <typename _Output_iterator, typename _Value_type> +_Event _Copy_async_impl(_Texture *_Tex, const size_t *_Tex_offset, unsigned int _Src_mipmap_level, const size_t *_Copy_extent, _Output_iterator _First, const size_t *_Preferred_copy_chunk_extent = NULL) +{ + _ASSERTE(_Tex != nullptr); + _ASSERTE(_Tex_offset != nullptr); + _ASSERTE(_Copy_extent != nullptr); + + // The copy region should be within the bounds of the source texture + _ASSERTE((_Tex_offset[0] + _Copy_extent[0]) <= _Tex->_Get_width(_Src_mipmap_level)); + _ASSERTE((_Tex_offset[1] + _Copy_extent[1]) <= _Tex->_Get_height(_Src_mipmap_level)); + _ASSERTE((_Tex_offset[2] + _Copy_extent[2]) <= _Tex->_Get_depth(_Src_mipmap_level)); + +#pragma warning( push ) +#pragma warning( disable : 4127 ) // conditional expression is constant + if ((sizeof(_Value_type) > sizeof(unsigned char)) && (_Tex->_Get_bits_per_element() != (8U * sizeof(_Value_type)))) + { + throw runtime_exception("Iterator-based copy is not supported on textures where the size of the _Value_type is not equal to the texel size.", E_INVALIDARG); + } +#pragma warning( pop ) + + // If the texture is available on the host then we can perform the copy entirely on the host + if (_Tex->_Get_host_ptr() != nullptr) + { + // We have made sure that the three multiplications below won't cause integer overflow when creating the texture + _ASSERTE(((_Tex->_Get_bits_per_element() * _Copy_extent[0]) % 8U) == 0); + + size_t _Row_size = (_Tex->_Get_bits_per_element() * _Copy_extent[0]) >> 3; // in bytes + size_t _Depth_slice_size = _Row_size * _Copy_extent[1]; + + size_t _Row_pitch = _Tex->_Get_row_pitch(); + size_t _Depth_pitch = _Tex->_Get_depth_pitch(); + _ASSERTE(_Row_pitch >= _Row_size); + _ASSERTE(_Depth_pitch >= _Depth_slice_size); + + size_t _Tex_offset_in_bytes = ((_Tex_offset[0] * _Tex->_Get_bits_per_element()) >> 3) + + (_Tex_offset[1] * _Row_pitch) + (_Tex_offset[2] * _Depth_pitch); + + unsigned char *_PTex = reinterpret_cast<unsigned char*>(_Tex->_Get_host_ptr()) + _Tex_offset_in_bytes; + + _Copy_data_on_host(_Tex->_Get_rank(), reinterpret_cast<_Value_type*>(_PTex), _First, + _Row_size / sizeof(_Value_type), _Copy_extent[1], _Copy_extent[2], + _Row_pitch, _Depth_pitch, _Row_size / sizeof(_Value_type), _Depth_slice_size / sizeof(_Value_type)); + + return _Event(); + } + + // The texture is not accessbile on the host; we need to copy to/from a staging + // texture before the copy to the destination. This is done in chunks, such that + // we can concurrently copy from the source texture to a staging texture while + // copying from a staging texture from a previous chunk to the destination. + _Event _Ev; + + // Determine the copy chunk extent + std::array<size_t, 3> _Copy_chunk_extent; + if (_Preferred_copy_chunk_extent != nullptr) + { + std::copy(&_Preferred_copy_chunk_extent[0], &_Preferred_copy_chunk_extent[3], _Copy_chunk_extent.begin()); + } + else + { + _Get_preferred_copy_chunk_extent(_Tex->_Get_rank(), _Copy_extent[0], _Copy_extent[1], _Copy_extent[2], _Tex->_Get_bits_per_element(), _Copy_chunk_extent.data()); + } + + std::array<size_t, 3> _Curr_copy_offset; + std::copy(&_Tex_offset[0], &_Tex_offset[3], _Curr_copy_offset.begin()); + + std::array<size_t, 3> _Remaining_copy_extent; + std::copy(&_Copy_extent[0], &_Copy_extent[3], _Remaining_copy_extent.begin()); + + bool _Truncated_copy = false; + + _Texture_ptr _Staging_tex_ptr; + std::array<size_t, 3> _Curr_copy_extent; + _Truncated_copy = _Get_chunked_staging_texture(_Tex, _Copy_chunk_extent.data(), _Remaining_copy_extent.data(), _Curr_copy_extent.data(), &_Staging_tex_ptr); + + // Now copy into the temp staging texture + std::array<size_t, 3> _Staging_tex_offset; + _Staging_tex_offset.fill(0); + _Event _Temp_ev = _Copy_async_impl(_Tex, _Curr_copy_offset.data(), _Src_mipmap_level, + _Staging_tex_ptr._Get_ptr(), _Staging_tex_offset.data(), /*_Dst_mipmap_level=*/0, + _Curr_copy_extent.data(), _Copy_chunk_extent.data()); + _Ev = _Ev._Add_event(_Temp_ev); + + // If we have finished our copy, we just need to add a continuation to copy + // from the temporary staging texture to the _Dst pointer + if (!_Truncated_copy) + { + return _Ev._Add_continuation(std::function<_Event()>([_Staging_tex_ptr, + _Curr_copy_extent, _Staging_tex_offset, _Copy_chunk_extent, _First]() mutable -> _Event + { + return _Copy_async_impl<_Output_iterator, _Value_type>(_Staging_tex_ptr, _Staging_tex_offset.data(), /*_Src_mipmap_level=*/0, _Curr_copy_extent.data(), _First, _Copy_chunk_extent.data()); + })); + } + else + { + // The copy was truncated. We need to recursively perform the rest of the copy + _Texture_ptr _Tex_ptr = _Tex; + _Curr_copy_offset[_Tex->_Get_rank() - 1] += _Curr_copy_extent[_Tex->_Get_rank() - 1]; + return _Ev._Add_continuation(std::function<_Event()>([_Staging_tex_ptr, _First, _Curr_copy_extent, + _Staging_tex_offset, _Tex_ptr, _Curr_copy_offset, _Remaining_copy_extent, _Copy_chunk_extent, _Src_mipmap_level]() mutable -> _Event + { + // Initiate copying of the remaining portion + _Output_iterator _New_dst_iter = _First; + _Advance_output_iterator<decltype(_New_dst_iter), size_t>(_New_dst_iter, (((_Curr_copy_extent[0] * _Tex_ptr->_Get_bits_per_element()) >> 3) / sizeof(_Value_type)) * _Curr_copy_extent[1] * _Curr_copy_extent[2]); + _Event _Ev1 = _Copy_async_impl<_Output_iterator, _Value_type>(_Tex_ptr, _Curr_copy_offset.data(), _Src_mipmap_level, _Remaining_copy_extent.data(), _New_dst_iter, _Copy_chunk_extent.data()); + + // Now copy the data from the temp staging buffer to the _Dst pointer + _Event _Ev2 = _Copy_async_impl<_Output_iterator, _Value_type>(_Staging_tex_ptr, _Staging_tex_offset.data(), /*_Src_mipmap_level=*/0, _Curr_copy_extent.data(), _First, _Copy_chunk_extent.data()); + + return _Ev2._Add_event(_Ev1); + })); + } +} + +template <typename _Value_type, int _Rank> +_Event _Copy_async_impl(const void * _Src, unsigned int _Src_byte_size, const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent) +{ + _Is_valid_section(_Dst.extent, _Dst_offset, _Copy_extent); + + if (_Dst.get_mipmap_levels() > 1) + { + throw runtime_exception("Invalid destination - multiple mipmap levels cannot be copied from source", E_INVALIDARG); + } + + if (_Src_byte_size < _Get_section_size(_Dst, _Copy_extent)) + { + if (_Dst.extent == _Copy_extent) + { + throw runtime_exception("Invalid _Src_byte_size argument. _Src_byte_size is smaller than the total size of _Dst.", E_INVALIDARG); + } + else + { + throw runtime_exception("Invalid _Src_byte_size argument. _Src_byte_size is smaller than the provided section of _Dst.", E_INVALIDARG); + } + } + + _Texture *_Dst_tex_ptr = _Get_texture(_Dst); + std::array<size_t, 3> _Copy_extent_arr = _Get_dimensions(_Copy_extent, /*_Mip_offset=*/0); + std::array<size_t, 3> _Dst_offset_arr = _Get_indices(_Dst_offset); + auto _First = stdext::make_unchecked_array_iterator(reinterpret_cast<const unsigned char*>(_Src)); + auto _Last = stdext::make_unchecked_array_iterator(reinterpret_cast<const unsigned char*>(_Src) + _Src_byte_size); + + return _Copy_async_impl<decltype(_First), unsigned char>(_First, _Last, _Dst_tex_ptr, _Dst_offset_arr.data(), _Get_texture_descriptor(_Dst)._Get_most_detailed_mipmap_level(), _Copy_extent_arr.data()); +} + +template<typename _Value_type, int _Rank> +_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset, const extent<_Rank> &_Copy_extent, _Out_ void * _Dst, unsigned int _Dst_byte_size) +{ + _Is_valid_section(_Src.extent, _Src_offset, _Copy_extent); + + if (_Src.get_mipmap_levels() > 1) + { + throw runtime_exception("Invalid source - multiple mipmap levels cannot be copied to destination", E_INVALIDARG); + } + + if (_Get_section_size(_Src, _Copy_extent) > _Dst_byte_size) + { + if (_Src.extent == _Copy_extent) + { + throw runtime_exception("Invalid _Dst_byte_size argument. _Dst_byte_size is smaller than the size of _Src.", E_INVALIDARG); + } + else + { + throw runtime_exception("Invalid _Dst_byte_size argument. _Dst_byte_size is smaller than the provided section of _Src.", E_INVALIDARG); + } + } + + _Texture *_Src_tex_ptr = _Get_texture(_Src); + std::array<size_t, 3> _Copy_extent_arr = _Get_dimensions(_Copy_extent, /*_Mip_offset=*/0); + std::array<size_t, 3> _Src_offset_arr = _Get_indices(_Src_offset); + + auto _First = stdext::make_unchecked_array_iterator(reinterpret_cast<unsigned char*>(_Dst)); + + return _Copy_async_impl<decltype(_First), unsigned char>(_Src_tex_ptr, _Src_offset_arr.data(), _Get_texture_descriptor(_Src)._Get_most_detailed_mipmap_level(), _Copy_extent_arr.data(), _First); +} + +template <typename _Output_iterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank> &_Src, const index<_Rank> &_Src_offset, const extent<_Rank> &_Copy_extent, _Output_iterator _Dest_iter) +{ + _Is_valid_section(_Src.extent, _Src_offset, _Copy_extent); + + if (_Src.get_mipmap_levels() > 1) + { + throw runtime_exception("Invalid source - multiple mipmap levels cannot be copied to destination", E_INVALIDARG); + } + + _Texture *_Src_tex_ptr = _Get_texture(_Src); + std::array<size_t, 3> _Copy_extent_arr = _Get_dimensions(_Copy_extent, /*_Mip_offset=*/0); + std::array<size_t, 3> _Src_offset_arr = _Get_indices(_Src_offset); + + return _Copy_async_impl<_Output_iterator, _Value_type>(_Src_tex_ptr, _Src_offset_arr.data(), _Get_texture_descriptor(_Src)._Get_most_detailed_mipmap_level(), _Copy_extent_arr.data(), _Dest_iter); +} + +template <typename _Input_iterator, typename _Value_type, int _Rank> +_Event _Copy_async_impl(_Input_iterator _First, _Input_iterator _Last, const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent) +{ + _Is_valid_section(_Dst.extent, _Dst_offset, _Copy_extent); + if (static_cast<unsigned int>(std::distance(_First, _Last)) < _Copy_extent.size()) + { + throw runtime_exception("Inadequate amount of data supplied through the iterators", E_INVALIDARG); + } + + if (_Dst.get_mipmap_levels() > 1) + { + throw runtime_exception("Invalid destination - multiple mipmap levels cannot be copied from source", E_INVALIDARG); + } + + std::array<size_t, 3> _Copy_extent_arr = _Get_dimensions(_Copy_extent, /*_Mip_offset=*/0); + std::array<size_t, 3> _Dst_offset_arr = _Get_indices(_Dst_offset); + + _Texture *_Dst_tex_ptr = _Get_texture(_Dst); + return _Copy_async_impl<_Input_iterator, _Value_type>(_First, _Last, _Dst_tex_ptr, _Dst_offset_arr.data(), _Get_texture_descriptor(_Dst)._Get_most_detailed_mipmap_level(), _Copy_extent_arr.data()); +} + +template<typename _Value_type, int _Rank> +_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset, + const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, + const extent<_Rank> &_Copy_extent) +{ + _Is_valid_section(_Src.extent, _Src_offset, _Copy_extent); + _Is_valid_section(_Dst.extent, _Dst_offset, _Copy_extent); + + _Texture_descriptor _Src_tex_desc = _Get_texture_descriptor(_Src); + _Texture_descriptor _Dst_tex_desc = _Get_texture_descriptor(_Dst); + + if (_Src_tex_desc._Get_view_mipmap_levels() != _Dst_tex_desc._Get_view_mipmap_levels()) + { + throw runtime_exception("The source and destination textures must have the exactly the same number of mipmap levels for texture copy.", E_INVALIDARG); + } + + bool _Is_whole_texture_copy = (_Src_offset == _Dst_offset && _Src_offset == index<_Rank>() && _Src.extent == _Dst.extent && _Src.extent == _Copy_extent); + + if (_Src_tex_desc._Get_view_mipmap_levels() > 1 && !_Is_whole_texture_copy) + { + throw runtime_exception("Sections are not allowed when copy involves multiple mipmap levels", E_INVALIDARG); + } + + if (_Src_tex_desc._Are_mipmap_levels_overlapping(&_Dst_tex_desc)) + { + throw runtime_exception("The source and destination are overlapping areas on the same texture", E_INVALIDARG); + } + + _Texture* _Src_tex = _Get_texture(_Src); + _Texture* _Dst_tex = _Get_texture(_Dst); + + // Formats must be identical for non-adopted textures. Textures created through D3D interop are not subject to this test + // to allow copy between related, but not identical, formats. Attempting to copy between unrelated formats through interop + // will result in exceptions in debug mode and undefined behavior in release mode. + if (!_Src_tex->_Is_adopted() && !_Dst_tex->_Is_adopted() && (_Src_tex->_Get_texture_format() != _Dst_tex->_Get_texture_format())) + { + throw runtime_exception("The source and destination textures are not compatible.", E_INVALIDARG); + } + + std::array<size_t, 3> _Src_offset_arr = _Get_indices(_Src_offset); + std::array<size_t, 3> _Dst_offset_arr = _Get_indices(_Dst_offset); + + _Event _Copy_event; + + unsigned int _Src_most_detailed_mipmap_level = _Src_tex_desc._Get_most_detailed_mipmap_level(); + unsigned int _Dst_most_detailed_mipmap_level = _Dst_tex_desc._Get_most_detailed_mipmap_level(); + + // Copy all mipmap levels from source to destination one by one. + // Note that the offsets are not allowed therefore only dimensions need to be updated for subsequent mipmap levels + for (unsigned int _Mip_offset = 0; _Mip_offset < _Src_tex_desc._Get_view_mipmap_levels(); ++_Mip_offset) + { + std::array<size_t, 3> _Copy_extent_arr = _Get_dimensions(_Copy_extent, _Mip_offset); + + auto _Step_event = _Copy_async_impl(_Src_tex, _Src_offset_arr.data(), _Src_most_detailed_mipmap_level + _Mip_offset, + _Dst_tex, _Dst_offset_arr.data(), _Dst_most_detailed_mipmap_level + _Mip_offset, + _Copy_extent_arr.data()); + + _Copy_event = _Copy_event._Add_event(_Step_event); + } + + return _Copy_event; +} + +} // namespace details + +/// <summary> +/// Copies the contents of the source texture into the destination host buffer. +/// </summary> +/// <param name="_Rank"> +/// The rank of the source texture. +/// </param> +/// <param name="_Value_type"> +/// The type of the elements of the source texture. +/// </param> +/// <param name="_Src"> +/// The source texture or texture_view. +/// </param> +/// <param name="_Dst"> +/// The destination host buffer. +/// </param> +/// <param name="_Dst_byte_size"> +/// Number of bytes in the destination buffer. +/// </param> +template <typename _Src_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture, void>::type> void copy(const _Src_type &_Src, _Out_ void * _Dst, unsigned int _Dst_byte_size) +{ + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Src.extent)); + + details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Src.extent, _Dst, _Dst_byte_size)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies the contents of a section of the source texture into the destination host buffer. +/// </summary> +/// <param name="_Rank"> +/// The rank of the source texture. +/// </param> +/// <param name="_Value_type"> +/// The type of the elements of the source texture. +/// </param> +/// <param name="_Src"> +/// The source texture or texture_view. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <param name="_Dst"> +/// The destination host buffer. +/// </param> +/// <param name="_Dst_byte_size"> +/// Number of bytes in the destination buffer. +/// </param> +template <typename _Src_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture, void>::type> void copy(const _Src_type &_Src, const index<_Src_type::rank> &_Src_offset, const extent<_Src_type::rank> &_Copy_extent, _Out_ void * _Dst, unsigned int _Dst_byte_size) +{ + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Copy_extent)); + + details::_Copy_async_impl(_Src, _Src_offset, _Copy_extent, _Dst, _Dst_byte_size)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + + +/// <summary> +/// Copies the contents of the source host buffer into the destination texture _Dst. +/// </summary> +/// <param name="_Rank"> +/// The rank of the destination texture. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture or texture_view. +/// </param> +/// <param name="_Src"> +/// The source host buffer. +/// </param> +/// <param name="_Src_byte_size"> +/// Number of bytes in the source buffer. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +template <typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(const void * _Src, unsigned int _Src_byte_size, _Dst_type & _Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + details::_Copy_async_impl(_Src, _Src_byte_size, _Dst, index<_Dst_type::rank>(), _Dst.extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies the contents of the source host buffer into a section of the destination texture _Dst. +/// </summary> +/// <param name="_Dst_type"> +/// The type of the destination texture or texture_view. +/// </param> +/// <param name="_Src"> +/// The source host buffer. +/// </param> +/// <param name="_Src_byte_size"> +/// Number of bytes in the source buffer. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +template <typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(const void * _Src, unsigned int _Src_byte_size, _Dst_type & _Dst, + const index<_Dst_type::rank> &_Dst_offset, const extent<_Dst_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Copy_extent)); + + details::_Copy_async_impl(_Src, _Src_byte_size, _Dst, _Dst_offset, _Copy_extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + + +/// <summary> +/// Asynchronously copies the contents of the source texture into the destination host buffer. +/// </summary> +/// <param name="_Rank"> +/// The rank of the source texture. +/// </param> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Src"> +/// The source texture or texture_view. +/// </param> +/// <param name="_Dst"> +/// The destination host buffer. +/// </param> +/// <param name="_Dst_byte_size"> +/// Number of bytes in the destination buffer. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template<typename _Src_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture, void>::type> concurrency::completion_future copy_async(const _Src_type &_Src, _Out_ void * _Dst, unsigned int _Dst_byte_size) +{ + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Src.extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Src.extent, _Dst, _Dst_byte_size); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies the contents of the provided section of the source texture into the destination host buffer. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Src"> +/// The source texture or texture_view. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <param name="_Dst"> +/// The destination host buffer. +/// </param> +/// <param name="_Dst_byte_size"> +/// Number of bytes in the destination buffer. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template<typename _Src_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture, void>::type> concurrency::completion_future copy_async(const _Src_type &_Src, const index<_Src_type::rank> &_Src_offset, const extent<_Src_type::rank> &_Copy_extent, + _Out_ void * _Dst, unsigned int _Dst_byte_size) +{ + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Copy_extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, _Src_offset, _Copy_extent, _Dst, _Dst_byte_size); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies the contents of the source host buffer into the destination texture _Dst. +/// </summary> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source host buffer. +/// </param> +/// <param name="_Src_byte_size"> +/// Number of bytes in the source buffer. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(const void * _Src, unsigned int _Src_byte_size, _Dst_type & _Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, _Src_byte_size, _Dst, index<_Dst_type::rank>(), _Dst.extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies the contents of the source host buffer into a section of the destination texture _Dst. +/// </summary> +/// <param name="_Dst_type"> +/// The type of the elements of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source host buffer. +/// </param> +/// <param name="_Src_byte_size"> +/// Number of bytes in the source buffer. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(const void * _Src, unsigned int _Src_byte_size, _Dst_type & _Dst, + const index<_Dst_type::rank> &_Dst_offset, const extent<_Dst_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Copy_extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, _Src_byte_size, _Dst, _Dst_offset, _Copy_extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Copies data from the pair of source iterators into the destination texture _Dst. +/// </summary> +/// <param name="InputIterator"> +/// The input iterator type. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_First"> +/// The starting iterator for the copy. +/// </param> +/// <param name="_Last"> +/// The ending iterator for the copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +template <typename InputIterator, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(InputIterator _First, InputIterator _Last, _Dst_type &_Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + details::_Copy_async_impl(_First, _Last, _Dst, index<_Dst_type::rank>(), _Dst.extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies data from the pair of source iterators into a section of the destination texture _Dst. +/// </summary> +/// <param name="InputIterator"> +/// The input iterator type. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_First"> +/// The starting iterator for the copy. +/// </param> +/// <param name="_Last"> +/// The ending iterator for the copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +template <typename InputIterator, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(InputIterator _First, InputIterator _Last, _Dst_type &_Dst, const index<_Dst_type::rank> &_Dst_offset, const extent<_Dst_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Copy_extent)); + + details::_Copy_async_impl(_First, _Last, _Dst, _Dst_offset, _Copy_extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies data from the source texture _Src into an output iterator. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="OutputIterator"> +/// The output iterator type. +/// </param> +/// <param name="_Dst"> +/// The starting iterator for the copy output. +/// </param> +template <typename _Src_type, typename OutputIterator, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && !details::texture_traits<OutputIterator>::is_texture, void>::type> void copy(const _Src_type &_Src, OutputIterator _Dst) +{ + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Src.extent)); + + details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Src.extent, _Dst)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies data from a section of the source texture _Src into an output iterator. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="OutputIterator"> +/// The output iterator type. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <param name="_Dst"> +/// The starting iterator for the copy output. +/// </param> +template <typename _Src_type, typename OutputIterator, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && !details::texture_traits<OutputIterator>::is_texture, void>::type> void copy(const _Src_type &_Src, const index<_Src_type::rank> &_Src_offset, const extent<_Src_type::rank> &_Copy_extent, OutputIterator _Dst) +{ + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Copy_extent)); + + details::_Copy_async_impl(_Src, _Src_offset, _Copy_extent, _Dst)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies data from the source texture _Src into the destination texture _Dst. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source texture from which to copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture into which to copy. +/// </param> +template <typename _Src_type, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(const _Src_type &_Src, _Dst_type &_Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + + if (_Src.extent != _Dst.extent) + { + throw runtime_exception("The source and destination textures must have the exactly the same extent for whole-texture copy.", E_INVALIDARG); + } + + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Dst, index<_Dst_type::rank>(), _Dst.extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Copies data from a section of the source texture _Src into a section of the destination texture _Dst. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source texture from which to copy. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Dst"> +/// The destination texture into which to copy. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +template <typename _Src_type, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && details::texture_traits<_Dst_type>::is_texture, void>::type> void copy(const _Src_type &_Src, const index<_Src_type::rank> &_Src_offset, _Dst_type &_Dst, const index<_Dst_type::rank> &_Dst_offset, const extent<_Src_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Span_id = concurrency::details::_Get_amp_trace()->_Start_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Src, _Copy_extent)); + + details::_Copy_async_impl(_Src, _Src_offset, _Dst, _Dst_offset, _Copy_extent)._Get(); + + concurrency::details::_Get_amp_trace()->_Write_end_event(_Span_id); +} + +/// <summary> +/// Asynchronously copies data from the pair of source iterators into the destination texture _Dst. +/// </summary> +/// <param name="InputIterator"> +/// The input iterator type. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_First"> +/// The starting iterator for the copy. +/// </param> +/// <param name="_Last"> +/// The ending iterator for the copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(InputIterator _First, InputIterator _Last, _Dst_type &_Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + _Event _Ev = details::_Copy_async_impl<InputIterator, _Dst_type::value_type, _Dst_type::rank>(_First, _Last, _Dst, index<_Dst_type::rank>(), _Dst.extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies data from the pair of source iterators into a section of the destination texture _Dst. +/// </summary> +/// <param name="InputIterator"> +/// The input iterator type. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_First"> +/// The starting iterator for the copy. +/// </param> +/// <param name="_Last"> +/// The ending iterator for the copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture or texture_view. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename InputIterator, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(InputIterator _First, InputIterator _Last, _Dst_type &_Dst, + const index<_Dst_type::rank> &_Dst_offset, const extent<_Dst_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr, + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Copy_extent)); + + _Event _Ev = details::_Copy_async_impl<InputIterator, _Dst_type::value_type, _Dst_type::rank>(_First, _Last, _Dst, _Dst_offset, _Copy_extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies data from the source texture _Src into an output iterator. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="OutputIterator"> +/// The output iterator type. +/// </param> +/// <param name="_Dst"> +/// The starting iterator for the copy output. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Src_type, typename OutputIterator, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && !details::texture_traits<OutputIterator>::is_texture, void>::type> concurrency::completion_future copy_async(_Src_type &_Src, OutputIterator _Dst) +{ + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Src.extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Src.extent, _Dst); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies data from a section of the source texture _Src into an output iterator. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="OutputIterator"> +/// The output iterator type. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <param name="_Dst"> +/// The starting iterator for the copy output. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Src_type, typename OutputIterator, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && !details::texture_traits<OutputIterator>::is_texture, void>::type> concurrency::completion_future copy_async(_Src_type &_Src, const index<_Src_type::rank> &_Src_offset, const extent<_Src_type::rank> &_Copy_extent, OutputIterator _Dst) +{ + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + nullptr, + _Get_section_size(_Src, _Copy_extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, _Src_offset, _Copy_extent, _Dst); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies data from the source texture _Src into the destination texture _Dst. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source texture from which to copy. +/// </param> +/// <param name="_Dst"> +/// The destination texture into which to copy. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Src_type, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(_Src_type &_Src, _Dst_type &_Dst) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + + if (_Src.extent != _Dst.extent) + { + throw runtime_exception("The source and destination textures must have the exactly the same extent for whole-texture copy.", E_INVALIDARG); + } + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Dst, _Dst.extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, index<_Src_type::rank>(), _Dst, index<_Dst_type::rank>(), _Dst.extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +/// <summary> +/// Asynchronously copies data from a section of the source texture _Src into the destination texture _Dst. +/// </summary> +/// <param name="_Src_type"> +/// The type of the source texture. +/// </param> +/// <param name="_Dst_type"> +/// The type of the destination texture. +/// </param> +/// <param name="_Src"> +/// The source texture from which to copy. +/// </param> +/// <param name="_Src_offset"> +/// The offset into the source texture from which to begin copying. +/// </param> +/// <param name="_Dst"> +/// The destination texture into which to copy. +/// </param> +/// <param name="_Dst_offset"> +/// The offset into the destination texture to which to begin copying. +/// </param> +/// <param name="_Copy_extent"> +/// The extent of the texture section to copy. +/// </param> +/// <returns> +/// A future upon which to wait for the operation to complete. +/// </returns> +template <typename _Src_type, typename _Dst_type, typename = typename std::enable_if<details::texture_traits<_Src_type>::is_texture && details::texture_traits<_Dst_type>::is_texture, void>::type> concurrency::completion_future copy_async(_Src_type &_Src, const index<_Src_type::rank> &_Src_offset, _Dst_type &_Dst, const index<_Dst_type::rank> &_Dst_offset, const extent<_Src_type::rank> &_Copy_extent) +{ + static_assert(details::texture_traits<_Dst_type>::is_writable, "Destination is not a writable texture type."); + + auto _Async_op_id = concurrency::details::_Get_amp_trace()->_Launch_async_copy_event_helper(concurrency::details::_Get_texture_descriptor(_Src), + concurrency::details::_Get_texture_descriptor(_Dst), + _Get_section_size(_Src, _Copy_extent)); + + _Event _Ev = details::_Copy_async_impl(_Src, _Src_offset, _Dst, _Dst_offset, _Copy_extent); + + return concurrency::details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev); +} + +namespace details +{ +template<int _Rank> +Concurrency::extent<_Rank> _Make_texture(const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_texture, _Texture_base_type_id _Id, _Inout_ _Texture ** _Tex, DXGI_FORMAT _View_format) __CPU_ONLY +{ + if (_D3D_texture == NULL) + { + throw runtime_exception("NULL D3D texture pointer.", E_INVALIDARG); + } + + if (!Concurrency::details::_Is_D3D_accelerator_view(_Av)) { + throw runtime_exception("Cannot create D3D texture on a non-D3D accelerator_view.", E_INVALIDARG); + } + + _Texture * _Tex_ptr = _Texture::_Adopt_texture(_Rank, _Id, _D3D_texture, _Av, _View_format); + if (_Tex_ptr->_Is_staging()) + { + _Tex_ptr->_Map_buffer(_Write_access, true /* _Wait */); + } + Concurrency::extent<_Rank> _Ext = Concurrency::graphics::details::_Create_extent<_Rank>(_Tex_ptr->_Get_width(), _Tex_ptr->_Get_height(), _Tex_ptr->_Get_depth()); + + _Is_valid_extent(_Ext); + details::_Is_valid_data_length(_Ext.size(), _Tex_ptr->_Get_bits_per_element()); + + *_Tex = _Tex_ptr; + return _Ext; +} + +#pragma warning( pop ) +} // namespace details + +namespace direct3d +{ + /// <summary> + /// Get the D3D texture interface underlying a texture. + /// </summary> + /// <param name="_Rank"> + /// The rank of the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements in the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Texture"> + /// A texture on a D3D accelerator_view for which the underlying D3D texture interface is returned. + /// </param> + /// <returns> + /// The IUnknown interface pointer corresponding to the D3D texture underlying the texture. + /// </returns> + template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_texture(const texture<_Value_type, _Rank> &_Texture) __CPU_ONLY + { + return Concurrency::details::_D3D_interop::_Get_D3D_texture(Concurrency::details::_Get_texture(_Texture)); + } + + /// <summary> + /// Get the D3D texture interface underlying a texture viewed by a writeonly_texture_view. + /// </summary> + /// <param name="_Rank"> + /// The rank of the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements in the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Texture"> + /// A writeonly_texture_view of a texture on a D3D accelerator_view for which the underlying D3D texture interface is returned. + /// </param> + /// <returns> + /// The IUnknown interface pointer corresponding to the D3D texture underlying the texture. + /// </returns> +#pragma warning( push ) +#pragma warning( disable : 4996 ) //writeonly_texture_view is deprecated + template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_texture(const writeonly_texture_view<_Value_type, _Rank> &_Texture) __CPU_ONLY + { + return Concurrency::details::_D3D_interop::_Get_D3D_buffer(Concurrency::details::_Get_texture(_Texture)); + } +#pragma warning( pop ) + + /// <summary> + /// Get the D3D texture interface underlying a texture viewed by a texture_view. + /// </summary> + /// <param name="_Rank"> + /// The rank of the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements in the texture to get underlying D3D texture of. + /// </param> + /// <param name="_Texture"> + /// A texture_view of a texture on a D3D accelerator_view for which the underlying D3D texture interface is returned. + /// </param> + /// <returns> + /// The IUnknown interface pointer corresponding to the D3D texture underlying the texture. + /// </returns> + template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_texture(const texture_view<_Value_type, _Rank> &_Texture) __CPU_ONLY + { + return Concurrency::details::_D3D_interop::_Get_D3D_buffer(Concurrency::details::_Get_texture(_Texture)); + } + + /// <summary> + /// Create an texture from a D3D texture interface pointer, optionally using the specified DXGI format for all + /// views on this texture. + /// </summary> + /// <param name="_Rank"> + /// The rank of the texture to be created from the D3D texture. + /// </param> + /// <param name="_Value_type"> + /// The type of the elements of the texture to be created from the D3D texture. + /// </param> + /// <param name="_Av"> + /// A D3D accelerator view on which the texture is to be created. + /// </param> + /// <param name="_D3D_texture"> + /// IUnknown interface pointer of the D3D texture to create the texture from. + /// </param> + /// <param name="_View_format"> + /// The DXGI format to use for views created from this texture. Pass DXGI_FORMAT_UNKNOWN (the default) + /// to derive the format from the underlying format of _D3D_texture and the _Value_type of this template. + /// The provided format must be compatible with the underlying format of _D3D_texture. + /// </param> + /// <returns> + /// A texture using the provided D3D texture. + /// </returns> + template<typename _Value_type, int _Rank> texture<_Value_type, _Rank> make_texture(const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_texture, + DXGI_FORMAT _View_format /*= DXGI_FORMAT_UKNNOWN*/) __CPU_ONLY + { + _Texture * _Tex_ptr = NULL; +#pragma warning( suppress: 6326 ) // Potential comparison of a constant with another constant + Concurrency::extent<_Rank> _Ext = Concurrency::graphics::details::_Make_texture<_Rank>(_Av, _D3D_texture, + _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type ? _Uint_type : _Short_vector_type_traits<_Value_type>::_Format_base_type_id, + &_Tex_ptr, _View_format); + + _ASSERTE(_Tex_ptr); + return texture<_Value_type, _Rank>(_Ext, _Texture_descriptor(_Tex_ptr)); + } + + /// <summary> + /// Get the D3D sampler state interface on the given accelerator view that represents the specified sampler object. + /// </summary> + /// <param name="_Av"> + /// A D3D accelerator view on which the D3D sampler state is to be created. + /// </param> + /// <param name="_Sampler"> + /// A sampler object for which the underlying D3D sampler state interface is created. + /// </param> + /// <returns> + /// The IUnknown interface pointer corresponding to the D3D sampler state that represents the given sampler. + /// </returns> + inline _Ret_ IUnknown * get_sampler(const Concurrency::accelerator_view &_Av, const sampler &_Sampler) __CPU_ONLY + { + return Concurrency::details::_D3D_interop::_Get_D3D_sampler(_Av, _Sampler._Get_sampler_ptr()); + } + + /// <summary> + /// Create a sampler from a D3D sampler state interface pointer. + /// </summary> + /// <param name="_D3D_sampler"> + /// IUnknown interface pointer of the D3D sampler state to create the sampler from. + /// </param> + /// <returns> + /// A sampler represents the provided D3D sampler state. + /// </returns> + inline sampler make_sampler(_In_ IUnknown *_D3D_sampler) __CPU_ONLY + { + return sampler(_Sampler_descriptor(_Sampler::_Create(_D3D_interop::_Get_D3D_sampler_data_ptr(_D3D_sampler)))); + } + + /// <summary> + /// Compares a 4-byte reference value and an 8-byte source value and + /// accumulates a vector of 4 sums. Each sum corresponds to the masked + /// sum of absolute differences of different byte alignments between + /// the reference value and the source value. + /// </summary> + /// <param name="_Reference"> + /// The reference array of 4 bytes in one uint value + /// </param> + /// <param name="_Source"> + /// The source array of 8 bytes in a vector of two uint values. + /// </param> + /// <param name="_Accum"> + /// A vector of 4 values to be added to the masked sum of absolute + /// differences of the different byte alignments between the reference + /// value and the source value. + /// </param> + /// <returns> + /// Returns a vector of 4 sums. Each sum corresponds to the masked sum + /// of absolute differences of different byte alignments between the reference + /// value and the source value. + /// </returns> + inline uint4 msad4(uint _Reference, uint2 _Source, uint4 _Accum) __GPU_ONLY + { + uint4 _Tmp; + __dp_d3d_msad4(reinterpret_cast<uint*>(&_Tmp), _Reference, _Source.x, _Source.y, _Accum.x, _Accum.y, _Accum.z, _Accum.w); + return _Tmp; + } +} // namespace direct3d + +} //namespace graphics +} //namespace Concurrency + + + diff --git a/test_data/lots_of_files/amp_math.h b/test_data/lots_of_files/amp_math.h new file mode 100644 index 0000000..359a97a --- /dev/null +++ b/test_data/lots_of_files/amp_math.h @@ -0,0 +1,4351 @@ +/*** +* ==++== +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* ==--== +* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +* +* amp_math.h +* +* C++ AMP Math Library +* +* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +****/ + +#pragma once + +#include <cmath> +#include <amprt.h> + +#define _AMP_MATH_H + +extern "C" +{ + +//============================================================================= +// fast_math intrinsics. +//============================================================================= +float __dp_d3d_absf(float) __GPU_ONLY; +float __dp_d3d_acosf(float) __GPU_ONLY; +float __dp_d3d_asinf(float) __GPU_ONLY; +float __dp_d3d_atanf(float) __GPU_ONLY; +float __dp_d3d_atan2f(float, float) __GPU_ONLY; +float __dp_d3d_ceilf(float) __GPU_ONLY; +float __dp_d3d_cosf(float) __GPU_ONLY; +float __dp_d3d_coshf(float) __GPU_ONLY; +float __dp_d3d_expf(float) __GPU_ONLY; +float __dp_d3d_exp2f(float) __GPU_ONLY; +float __dp_d3d_floorf(float) __GPU_ONLY; +float __dp_d3d_fmodf(float, float) __GPU_ONLY; +float __dp_d3d_fracf(float) __GPU_ONLY; +float __dp_d3d_frexpf(float, _Out_ float *) __GPU_ONLY; +int __dp_d3d_isfinitef(float)__GPU_ONLY; +int __dp_d3d_isinff(float) __GPU_ONLY; +int __dp_d3d_isnanf(float) __GPU_ONLY; +float __dp_d3d_ldexpf(float, float) __GPU_ONLY; +float __dp_d3d_logf(float) __GPU_ONLY; +float __dp_d3d_log10f(float) __GPU_ONLY; +float __dp_d3d_log2f(float) __GPU_ONLY; +float __dp_d3d_maxf(float, float) __GPU_ONLY; +float __dp_d3d_minf(float, float) __GPU_ONLY; +float __dp_d3d_modff(float, _Out_ float *) __GPU_ONLY; +float __dp_d3d_powf(float, float) __GPU_ONLY; +float __dp_d3d_roundf(float) __GPU_ONLY; +float __dp_d3d_rsqrtf(float) __GPU_ONLY; +int __dp_d3d_signf(float) __GPU_ONLY; +float __dp_d3d_sincosf(float, _Out_ float *) __GPU_ONLY; +float __dp_d3d_sinf(float) __GPU_ONLY; +float __dp_d3d_sinhf(float) __GPU_ONLY; +float __dp_d3d_sqrtf(float) __GPU_ONLY; +float __dp_d3d_tanf(float) __GPU_ONLY; +float __dp_d3d_tanhf(float) __GPU_ONLY; +float __dp_d3d_truncf(float) __GPU_ONLY; + +//============================================================================= +// Single-precision precise_math intrinsics. +//============================================================================= +float __dp_math_acosf(float) __GPU_ONLY; +float __dp_math_acoshf(float) __GPU_ONLY; +float __dp_math_asinf(float) __GPU_ONLY; +float __dp_math_asinhf(float) __GPU_ONLY; +float __dp_math_atanf(float) __GPU_ONLY; +float __dp_math_atan2f(float, float) __GPU_ONLY; +float __dp_math_atanhf(float) __GPU_ONLY; +float __dp_math_cbrtf(float) __GPU_ONLY; +float __dp_math_ceilf(float) __GPU_ONLY; +float __dp_math_copysignf(float, float) __GPU_ONLY; +float __dp_math_cosf(float) __GPU_ONLY; +float __dp_math_coshf(float) __GPU_ONLY; +float __dp_math_cospif(float) __GPU_ONLY; +float __dp_math_erff(float) __GPU_ONLY; +float __dp_math_erfcf(float) __GPU_ONLY; +float __dp_math_erfinvf(float) __GPU_ONLY; +float __dp_math_erfcinvf(float) __GPU_ONLY; +float __dp_math_expf(float) __GPU_ONLY; +float __dp_math_exp2f(float) __GPU_ONLY; +float __dp_math_exp10f(float) __GPU_ONLY; +float __dp_math_expm1f(float) __GPU_ONLY; +float __dp_math_fabsf(float) __GPU_ONLY; +float __dp_math_fdimf(float, float) __GPU_ONLY; +float __dp_math_floorf(float) __GPU_ONLY; +float __dp_math_fmaf(float, float, float) __GPU_ONLY; +float __dp_math_fmaxf(float, float) __GPU_ONLY; +float __dp_math_fminf(float, float) __GPU_ONLY; +float __dp_math_fmodf(float, float) __GPU_ONLY; +int __dp_math_fpclassifyf(float) __GPU_ONLY; +float __dp_math_frexpf(float, _Out_ int *) __GPU_ONLY; +float __dp_math_hypotf(float, float) __GPU_ONLY; +int __dp_math_ilogbf(float) __GPU_ONLY; +int __dp_math_isfinitef(float) __GPU_ONLY; +int __dp_math_isinff(float) __GPU_ONLY; +int __dp_math_isnanf(float) __GPU_ONLY; +int __dp_math_isnormalf(float) __GPU_ONLY; +float __dp_math_ldexpf(float, int) __GPU_ONLY; +float __dp_math_lgammaf(float, _Out_ int *) __GPU_ONLY; +float __dp_math_logf(float) __GPU_ONLY; +float __dp_math_log10f(float) __GPU_ONLY; +float __dp_math_log2f(float) __GPU_ONLY; +float __dp_math_log1pf(float) __GPU_ONLY; +float __dp_math_logbf(float) __GPU_ONLY; +float __dp_math_modff(float, _Out_ float *) __GPU_ONLY; +float __dp_math_nanf(int) __GPU_ONLY; +float __dp_math_nearbyintf(float) __GPU_ONLY; +float __dp_math_nextafterf(float, float) __GPU_ONLY; +float __dp_math_phif(float) __GPU_ONLY; +float __dp_math_powf(float, float) __GPU_ONLY; +float __dp_math_probitf(float) __GPU_ONLY; +float __dp_math_rcbrtf(float) __GPU_ONLY; +float __dp_math_remainderf(float, float) __GPU_ONLY; +float __dp_math_remquof(float, float, _Out_ int *) __GPU_ONLY; +float __dp_math_roundf(float) __GPU_ONLY; +float __dp_math_rsqrtf(float) __GPU_ONLY; +float __dp_math_scalbf(float, float) __GPU_ONLY; +float __dp_math_scalbnf(float, int) __GPU_ONLY; +int __dp_math_signbitf(float) __GPU_ONLY; +float __dp_math_sinf(float) __GPU_ONLY; +float __dp_math_sincosf(float, _Out_ float *) __GPU_ONLY; +float __dp_math_sinpif(float) __GPU_ONLY; +float __dp_math_sinhf(float) __GPU_ONLY; +float __dp_math_sqrtf(float) __GPU_ONLY; +float __dp_math_tanf(float) __GPU_ONLY; +float __dp_math_tanhf(float) __GPU_ONLY; +float __dp_math_tanpif(float) __GPU_ONLY; +float __dp_math_tgammaf(float) __GPU_ONLY; +float __dp_math_truncf(float) __GPU_ONLY; + +//============================================================================= +// Double-precision precise_math intrinsics. +//============================================================================= +double __dp_math_acos(double) __GPU_ONLY; +double __dp_math_acosh(double) __GPU_ONLY; +double __dp_math_asin(double) __GPU_ONLY; +double __dp_math_asinh(double) __GPU_ONLY; +double __dp_math_atan(double) __GPU_ONLY; +double __dp_math_atan2(double, double) __GPU_ONLY; +double __dp_math_atanh(double) __GPU_ONLY; +double __dp_math_cbrt(double) __GPU_ONLY; +double __dp_math_ceil(double) __GPU_ONLY; +double __dp_math_copysign(double, double) __GPU_ONLY; +double __dp_math_cos(double) __GPU_ONLY; +double __dp_math_cosh(double) __GPU_ONLY; +double __dp_math_cospi(double) __GPU_ONLY; +double __dp_math_erf(double) __GPU_ONLY; +double __dp_math_erfc(double) __GPU_ONLY; +double __dp_math_erfinv(double) __GPU_ONLY; +double __dp_math_erfcinv(double) __GPU_ONLY; +double __dp_math_exp(double) __GPU_ONLY; +double __dp_math_exp2(double) __GPU_ONLY; +double __dp_math_exp10(double) __GPU_ONLY; +double __dp_math_expm1(double) __GPU_ONLY; +double __dp_math_fabs(double) __GPU_ONLY; +double __dp_math_fdim(double, double) __GPU_ONLY; +double __dp_math_floor(double) __GPU_ONLY; +double __dp_math_fma(double, double, double) __GPU_ONLY; +double __dp_math_fmax(double, double) __GPU_ONLY; +double __dp_math_fmin(double, double) __GPU_ONLY; +double __dp_math_fmod(double, double) __GPU_ONLY; +int __dp_math_fpclassify(double) __GPU_ONLY; +double __dp_math_frexp(double, _Out_ int *) __GPU_ONLY; +double __dp_math_hypot(double, double) __GPU_ONLY; +int __dp_math_ilogb(double) __GPU_ONLY; +int __dp_math_isfinite(double) __GPU_ONLY; +int __dp_math_isinf(double) __GPU_ONLY; +int __dp_math_isnan(double) __GPU_ONLY; +int __dp_math_isnormal(double) __GPU_ONLY; +double __dp_math_ldexp(double, int) __GPU_ONLY; +double __dp_math_lgamma(double, _Out_ int *) __GPU_ONLY; +double __dp_math_log(double) __GPU_ONLY; +double __dp_math_log10(double) __GPU_ONLY; +double __dp_math_log2(double) __GPU_ONLY; +double __dp_math_log1p(double) __GPU_ONLY; +double __dp_math_logb(double) __GPU_ONLY; +double __dp_math_modf(double, _Out_ double *) __GPU_ONLY; +double __dp_math_nan(int) __GPU_ONLY; +double __dp_math_nearbyint(double) __GPU_ONLY; +double __dp_math_nextafter(double, double) __GPU_ONLY; +double __dp_math_phi(double) __GPU_ONLY; +double __dp_math_pow(double, double) __GPU_ONLY; +double __dp_math_probit(double) __GPU_ONLY; +double __dp_math_rcbrt(double) __GPU_ONLY; +double __dp_math_remainder(double, double) __GPU_ONLY; +double __dp_math_remquo(double, double, _Out_ int *) __GPU_ONLY; +double __dp_math_round(double) __GPU_ONLY; +double __dp_math_rsqrt(double) __GPU_ONLY; +double __dp_math_scalb(double, double) __GPU_ONLY; +double __dp_math_scalbn(double, int) __GPU_ONLY; +int __dp_math_signbit(double) __GPU_ONLY; +double __dp_math_sin(double) __GPU_ONLY; +double __dp_math_sincos(double, _Out_ double *) __GPU_ONLY; +double __dp_math_sinpi(double) __GPU_ONLY; +double __dp_math_sinh(double) __GPU_ONLY; +double __dp_math_sqrt(double) __GPU_ONLY; +double __dp_math_tan(double) __GPU_ONLY; +double __dp_math_tanh(double) __GPU_ONLY; +double __dp_math_tanpi(double) __GPU_ONLY; +double __dp_math_tgamma(double) __GPU_ONLY; +double __dp_math_trunc(double) __GPU_ONLY; +} + +namespace Concurrency +{ +/// <summary> +/// Functions in the fast_math namespace have lower accuracy, and support +/// only single-precision float. +/// </summary> +namespace fast_math +{ + /// <summary> + /// Returns the absolute value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the absolute value of the argument + /// </returns> + inline float fabsf(float _X) __GPU_ONLY + { + return __dp_d3d_absf(_X); + } + + /// <summary> + /// Returns the absolute value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the absolute value of the argument + /// </returns> + inline float fabs(float _X) __GPU_ONLY + { + return __dp_d3d_absf(_X); + } + + /// <summary> + /// Calculates the arccosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arccosine value of the argument + /// </returns> + inline float acosf(float _X) __GPU_ONLY + { + return __dp_d3d_acosf(_X); + } + + /// <summary> + /// Calculates the arccosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arccosine value of the argument + /// </returns> + inline float acos(float _X) __GPU_ONLY + { + return __dp_d3d_acosf(_X); + } + + /// <summary> + /// Calculates the arcsine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arcsine value of the argument + /// </returns> + inline float asinf(float _X) __GPU_ONLY + { + return __dp_d3d_asinf(_X); + } + + /// <summary> + /// Calculates the arcsine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arcsine value of the argument + /// </returns> + inline float asin(float _X) __GPU_ONLY + { + return __dp_d3d_asinf(_X); + } + + /// <summary> + /// Calculates the arctangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of the argument + /// </returns> + inline float atanf(float _X) __GPU_ONLY + { + return __dp_d3d_atanf(_X); + } + + /// <summary> + /// Calculates the arctangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of the argument + /// </returns> + inline float atan(float _X) __GPU_ONLY + { + return __dp_d3d_atanf(_X); + } + + /// <summary> + /// Calculates the arctangent of _Y/_X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of _Y/_X + /// </returns> + inline float atan2f(float _Y, float _X) __GPU_ONLY + { + return __dp_d3d_atan2f(_Y, _X); + } + + /// <summary> + /// Calculates the arctangent of _Y/_X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of _Y/_X + /// </returns> + inline float atan2(float _Y, float _X) __GPU_ONLY + { + return __dp_d3d_atan2f(_Y, _X); + } + + /// <summary> + /// Calculates the ceiling of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the ceiling of the argument + /// </returns> + inline float ceilf(float _X) __GPU_ONLY + { + return __dp_d3d_ceilf(_X); + } + + /// <summary> + /// Calculates the ceiling of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the ceiling of the argument + /// </returns> + inline float ceil(float _X) __GPU_ONLY + { + return __dp_d3d_ceilf(_X); + } + + /// <summary> + /// Calculates the cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of the argument + /// </returns> + inline float cosf(float _X) __GPU_ONLY + { + return __dp_d3d_cosf(_X); + } + + /// <summary> + /// Calculates the cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of the argument + /// </returns> + inline float cos(float _X) __GPU_ONLY + { + return __dp_d3d_cosf(_X); + } + + /// <summary> + /// Calculates the hyperbolic cosine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic cosine value of the argument + /// </returns> + inline float coshf(float _X) __GPU_ONLY + { + return __dp_d3d_coshf(_X); + } + + /// <summary> + /// Calculates the hyperbolic cosine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic cosine value of the argument + /// </returns> + inline float cosh(float _X) __GPU_ONLY + { + return __dp_d3d_coshf(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument + /// </returns> + inline float expf(float _X) __GPU_ONLY + { + return __dp_d3d_expf(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument + /// </returns> + inline float exp(float _X) __GPU_ONLY + { + return __dp_d3d_expf(_X); + } + + /// <summary> + /// Calculates the base-2 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 exponential of the argument + /// </returns> + inline float exp2f(float _X) __GPU_ONLY + { + return __dp_d3d_exp2f(_X); + } + + /// <summary> + /// Calculates the base-2 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 exponential of the argument + /// </returns> + inline float exp2(float _X) __GPU_ONLY + { + return __dp_d3d_exp2f(_X); + } + + /// <summary> + /// Calculates the floor of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floor of the argument + /// </returns> + inline float floorf(float _X) __GPU_ONLY + { + return __dp_d3d_floorf(_X); + } + + /// <summary> + /// Calculates the floor of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floor of the argument + /// </returns> + inline float floor(float _X) __GPU_ONLY + { + return __dp_d3d_floorf(_X); + } + + /// <summary> + /// Determine the maximum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the maximum numeric value of the arguments + /// </returns> + inline float fmaxf(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_maxf(_X, _Y); + } + + /// <summary> + /// Determine the maximum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the maximum numeric value of the arguments + /// </returns> + inline float fmax(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_maxf(_X, _Y); + } + + /// <summary> + /// Determine the minimum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the minimum numeric value of the arguments + /// </returns> + inline float fminf(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_minf(_X, _Y); + } + + /// <summary> + /// Determine the minimum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the minimum numeric value of the arguments + /// </returns> + inline float fmin(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_minf(_X, _Y); + } + + /// <summary> + /// Calculates the floating-point remainder of _X/_Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floating-point remainder of _X/_Y + /// </returns> + inline float fmodf(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_fmodf(_X, _Y); + } + + /// <summary> + /// Calculates the floating-point remainder of _X/_Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floating-point remainder of _X/_Y + /// </returns> + inline float fmod(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_fmodf(_X, _Y); + } + + /// <summary> + /// Gets the mantissa and exponent of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Exp"> + /// Returns the integer exponent of _X in floating-point value + /// </param> + /// <returns> + /// Returns the mantissa _X + /// </returns> + inline float frexpf(float _X, _Out_ int * _Exp) __GPU_ONLY + { + float _FExp = 0.0f; + float _M = __dp_d3d_frexpf(_X, &_FExp); + *_Exp = static_cast<int>(_FExp); + // Currently, the mantissa returned by d3d's frexp is always positive + // Fetch the sign bit from _X to match cmath frexp + *reinterpret_cast<unsigned int*>(&_M) = *reinterpret_cast<unsigned int*>(&_M) | (*reinterpret_cast<unsigned int*>(&_X) & 0x80000000); + return _M; + } + + /// <summary> + /// Gets the mantissa and exponent of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Exp"> + /// Returns the integer exponent of _X in floating-point value + /// </param> + /// <returns> + /// Returns the mantissa _X + /// </returns> + inline float frexp(float _X, _Out_ int * _Exp) __GPU_ONLY + { + return frexpf(_X, _Exp); + } + + /// <summary> + /// Determines whether the argument has a finite value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a finite value + /// </returns> + inline int isfinite(float _X) __GPU_ONLY + { + return __dp_d3d_isfinitef(_X); + } + + /// <summary> + /// Determines whether the argument is an infinity + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has an infinite value + /// </returns> + inline int isinf(float _X) __GPU_ONLY + { + return __dp_d3d_isinff(_X); + } + + /// <summary> + /// Determines whether the argument is a NaN + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a NaN value + /// </returns> + inline int isnan(float _X) __GPU_ONLY + { + return __dp_d3d_isnanf(_X); + } + + /// <summary> + /// Computes a real number from the mantissa and exponent + /// </summary> + /// <param name="_X"> + /// Floating-point value, mantissa + /// </param> + /// <param name="_Exp"> + /// Integer value, exponent + /// </param> + /// <returns> + /// Returns _X * 2^_Exp + /// </returns> + inline float ldexpf(float _X, int _Exp) __GPU_ONLY + { + float _FExp = static_cast<float>(_Exp); + return __dp_d3d_ldexpf(_X, _FExp); + } + + /// <summary> + /// Computes a real number from the mantissa and exponent + /// </summary> + /// <param name="_X"> + /// Floating-point value, mantissa + /// </param> + /// <param name="_Exp"> + /// Integer value, exponent + /// </param> + /// <returns> + /// Returns _X * 2^_Exp + /// </returns> + inline float ldexp(float _X, int _Exp) __GPU_ONLY + { + return ldexpf(_X, _Exp); + } + + /// <summary> + /// Calculates the base-e logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of the argument + /// </returns> + inline float logf(float _X) __GPU_ONLY + { + return __dp_d3d_logf(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of the argument + /// </returns> + inline float log(float _X) __GPU_ONLY + { + return __dp_d3d_logf(_X); + } + + /// <summary> + /// Calculates the base-10 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log10f(float _X) __GPU_ONLY + { + return __dp_d3d_log10f(_X); + } + + /// <summary> + /// Calculates the base-10 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log10(float _X) __GPU_ONLY + { + return __dp_d3d_log10f(_X); + } + + /// <summary> + /// Calculates the base-2 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 logarithm of the argument + /// </returns> + inline float log2f(float _X) __GPU_ONLY + { + return __dp_d3d_log2f(_X); + } + + /// <summary> + /// Calculates the base-2 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 logarithm of the argument + /// </returns> + inline float log2(float _X) __GPU_ONLY + { + return __dp_d3d_log2f(_X); + } + + /// <summary> + /// Splits _X into fractional and integer parts. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Ip"> + /// Returns the integer portion of _X in floating-point value + /// </param> + /// <returns> + /// Returns the signed fractional portion of _X + /// </returns> + inline float modff(float _X, float * _Ip) __GPU_ONLY + { + return __dp_d3d_modff(_X, _Ip); + } + + /// <summary> + /// Splits _X into fractional and integer parts. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Ip"> + /// Returns the integer portion of _X in floating-point value + /// </param> + /// <returns> + /// Returns the signed fractional portion of _X + /// </returns> + inline float modf(float _X, float * _Ip) __GPU_ONLY + { + return __dp_d3d_modff(_X, _Ip); + } + + /// <summary> + /// Calculates _X raised to the power of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value, base + /// </param> + /// <param name="_Y"> + /// Floating-point value, exponent + /// </param> + /// <returns> + /// Returns the value of _X raised to the power of _Y + /// </returns> + inline float powf(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_powf(_X, _Y); + } + + /// <summary> + /// Calculates _X raised to the power of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value, base + /// </param> + /// <param name="_Y"> + /// Floating-point value, exponent + /// </param> + /// <returns> + /// Returns the value of _X raised to the power of _Y + /// </returns> + inline float pow(float _X, float _Y) __GPU_ONLY + { + return __dp_d3d_powf(_X, _Y); + } + + /// <summary> + /// Rounds _X to the nearest integer + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the nearest integer of _X + /// </returns> + inline float roundf(float _X) __GPU_ONLY + { + return __dp_d3d_roundf(_X); + } + + /// <summary> + /// Rounds _X to the nearest integer + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the nearest integer of _X + /// </returns> + inline float round(float _X) __GPU_ONLY + { + return __dp_d3d_roundf(_X); + } + + /// <summary> + /// Returns the reciprocal of the square root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the square root of the argument + /// </returns> + inline float rsqrtf(float _X) __GPU_ONLY + { + return __dp_d3d_rsqrtf(_X); + } + + /// <summary> + /// Returns the reciprocal of the square root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the square root of the argument + /// </returns> + inline float rsqrt(float _X) __GPU_ONLY + { + return __dp_d3d_rsqrtf(_X); + } + + /// <summary> + /// Returns the sign of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sign of the argument + /// </returns> + inline int signbitf(float _X) __GPU_ONLY + { + return __dp_d3d_signf(_X); + } + + /// <summary> + /// Returns the sign of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sign of the argument + /// </returns> + inline int signbit(float _X) __GPU_ONLY + { + return __dp_d3d_signf(_X); + } + + /// <summary> + /// Calculates the sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of the argument + /// </returns> + inline float sinf(float _X) __GPU_ONLY + { + return __dp_d3d_sinf(_X); + } + + /// <summary> + /// Calculates the sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of the argument + /// </returns> + inline float sin(float _X) __GPU_ONLY + { + return __dp_d3d_sinf(_X); + } + + /// <summary> + /// Calculates sine and cosine value of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_S"> + /// Returns the sine value of _X + /// </param> + /// <param name="_C"> + /// Returns the cosine value of _X + /// </param> + inline void sincosf(float _X, float * _S, float * _C) __GPU_ONLY + { + *_C = __dp_d3d_sincosf(_X, _S); + } + + /// <summary> + /// Calculates sine and cosine value of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_S"> + /// Returns the sine value of _X + /// </param> + /// <param name="_C"> + /// Returns the cosine value of _X + /// </param> + inline void sincos(float _X, float * _S, float * _C) __GPU_ONLY + { + *_C = __dp_d3d_sincosf(_X, _S); + } + + /// <summary> + /// Calculates the hyperbolic sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic sine value of the argument + /// </returns> + inline float sinhf(float _X) __GPU_ONLY + { + return __dp_d3d_sinhf(_X); + } + + /// <summary> + /// Calculates the hyperbolic sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic sine value of the argument + /// </returns> + inline float sinh(float _X) __GPU_ONLY + { + return __dp_d3d_sinhf(_X); + } + + /// <summary> + /// Calculates the squre root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the squre root of the argument + /// </returns> + inline float sqrtf(float _X) __GPU_ONLY + { + return __dp_d3d_sqrtf(_X); + } + + /// <summary> + /// Calculates the squre root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the squre root of the argument + /// </returns> + inline float sqrt(float _X) __GPU_ONLY + { + return __dp_d3d_sqrtf(_X); + } + + /// <summary> + /// Calculates the tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of the argument + /// </returns> + inline float tanf(float _X) __GPU_ONLY + { + return __dp_d3d_tanf(_X); + } + + /// <summary> + /// Calculates the tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of the argument + /// </returns> + inline float tan(float _X) __GPU_ONLY + { + return __dp_d3d_tanf(_X); + } + + /// <summary> + /// Calculates the hyperbolic tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic tangent value of the argument + /// </returns> + inline float tanhf(float _X) __GPU_ONLY + { + return __dp_d3d_tanhf(_X); + } + /// <summary> + /// Calculates the hyperbolic tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic tangent value of the argument + /// </returns> + inline float tanh(float _X) __GPU_ONLY + { + return __dp_d3d_tanhf(_X); + } + + /// <summary> + /// Truncates the argument to the integer component + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the integer component of the argument + /// </returns> + inline float truncf(float _X) __GPU_ONLY + { + return __dp_d3d_truncf(_X); + } + + /// <summary> + /// Truncates the argument to the integer component + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the integer component of the argument + /// </returns> + inline float trunc(float _X) __GPU_ONLY + { + return __dp_d3d_truncf(_X); + } + + //============================================================================= + // Import CMATH C++ functions: + //============================================================================= + using std::acosf; + using std::asinf; + using std::atanf; + using std::atan2f; + using std::ceilf; + using std::cosf; + using std::coshf; + using std::expf; + using std::fabsf; + using std::floorf; + using std::fmodf; + using std::frexpf; + using std::ldexpf; + using std::logf; + using std::log10f; + using std::modff; + using std::powf; + using std::sinf; + using std::sinhf; + using std::sqrtf; + using std::tanf; + using std::tanhf; + + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + using std::exp2; + using std::exp2f; + using std::fmax; + using std::fmaxf; + using std::fmin; + using std::fminf; + using std::log2; + using std::log2f; + using std::round; + using std::roundf; + using std::trunc; + using std::truncf; + +} // namespace fast_math + + +/// <summary> +/// Functions in the precise_math namespace have higher accuracy, but require +/// double-precision support, which not all accelerators do. +/// </summary> +namespace precise_math +{ + /// <summary> + /// Calculates the arccosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arccosine value of the argument + /// </returns> + inline float acosf(float _X) __GPU_ONLY + { + return __dp_math_acosf(_X); + } + + /// <summary> + /// Calculates the arccosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arccosine value of the argument + /// </returns> + inline float acos(float _X) __GPU_ONLY + { + return __dp_math_acosf(_X); + } + + /// <summary> + /// Calculates the arccosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arccosine value of the argument + /// </returns> + inline double acos(double _X) __GPU_ONLY + { + return __dp_math_acos(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic cosine value of the argument + /// </returns> + inline float acoshf(float _X) __GPU_ONLY + { + return __dp_math_acoshf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic cosine value of the argument + /// </returns> + inline float acosh(float _X) __GPU_ONLY + { + return __dp_math_acoshf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic cosine value of the argument + /// </returns> + inline double acosh(double _X) __GPU_ONLY + { + return __dp_math_acosh(_X); + } + + + /// <summary> + /// Calculates the arcsine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arcsine value of the argument + /// </returns> + inline float asinf(float _X) __GPU_ONLY + { + return __dp_math_asinf(_X); + } + + /// <summary> + /// Calculates the arcsine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arcsine value of the argument + /// </returns> + inline float asin(float _X) __GPU_ONLY + { + return __dp_math_asinf(_X); + } + + /// <summary> + /// Calculates the arcsine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arcsine value of the argument + /// </returns> + inline double asin(double _X) __GPU_ONLY + { + return __dp_math_asin(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic sine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic sine value of the argument + /// </returns> + inline float asinhf(float _X) __GPU_ONLY + { + return __dp_math_asinhf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic sine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic sine value of the argument + /// </returns> + inline float asinh(float _X) __GPU_ONLY + { + return __dp_math_asinhf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic sine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic sine value of the argument + /// </returns> + inline double asinh(double _X) __GPU_ONLY + { + return __dp_math_asinh(_X); + } + + /// <summary> + /// Calculates the arctangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of the argument + /// </returns> + inline float atanf(float _X) __GPU_ONLY + { + return __dp_math_atanf(_X); + } + + /// <summary> + /// Calculates the arctangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of the argument + /// </returns> + inline float atan(float _X) __GPU_ONLY + { + return __dp_math_atanf(_X); + } + + /// <summary> + /// Calculates the arctangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of the argument + /// </returns> + inline double atan(double _X) __GPU_ONLY + { + return __dp_math_atan(_X); + } + + /// <summary> + /// Calculates the arctangent of _Y/_X + /// </summary> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of _Y/_X + /// </returns> + inline float atan2f(float _Y, float _X) __GPU_ONLY + { + return __dp_math_atan2f(_Y, _X); + } + + /// <summary> + /// Calculates the arctangent of _Y/_X + /// </summary> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of _Y/_X + /// </returns> + inline float atan2(float _Y, float _X) __GPU_ONLY + { + return __dp_math_atan2f(_Y, _X); + } + + /// <summary> + /// Calculates the arctangent of _Y/_X + /// </summary> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the arctangent value of _Y/_X + /// </returns> + inline double atan2(double _Y, double _X) __GPU_ONLY + { + return __dp_math_atan2(_Y, _X); + } + + + /// <summary> + /// Calculates the inverse hyperbolic tangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic tangent value of the argument + /// </returns> + inline float atanhf(float _X) __GPU_ONLY + { + return __dp_math_atanhf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic tangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic tangent value of the argument + /// </returns> + inline float atanh(float _X) __GPU_ONLY + { + return __dp_math_atanhf(_X); + } + + /// <summary> + /// Calculates the inverse hyperbolic tangent of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse hyperbolic tangent value of the argument + /// </returns> + inline double atanh(double _X) __GPU_ONLY + { + return __dp_math_atanh(_X); + } + + /// <summary> + /// Computes the real cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the real cube root of the argument + /// </returns> + inline float cbrtf(float _X) __GPU_ONLY + { + return __dp_math_cbrtf(_X); + } + + /// <summary> + /// Computes the real cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the real cube root of the argument + /// </returns> + inline float cbrt(float _X) __GPU_ONLY + { + return __dp_math_cbrtf(_X); + } + + /// <summary> + /// Computes the real cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the real cube root of the argument + /// </returns> + inline double cbrt(double _X) __GPU_ONLY + { + return __dp_math_cbrt(_X); + } + + /// <summary> + /// Calculates the ceiling of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the ceiling of the argument + /// </returns> + inline float ceilf(float _X) __GPU_ONLY + { + return __dp_math_ceilf(_X); + } + + /// <summary> + /// Calculates the ceiling of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the ceiling of the argument + /// </returns> + inline float ceil(float _X) __GPU_ONLY + { + return __dp_math_ceilf(_X); + } + + /// <summary> + /// Calculates the ceiling of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the ceiling of the argument + /// </returns> + inline double ceil(double _X) __GPU_ONLY + { + return __dp_math_ceil(_X); + } + + /// <summary> + /// Produces a value with the magnitude of _X and the sign of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a value with the magnitude of _X and the sign of _Y + /// </returns> + inline float copysignf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_copysignf(_X, _Y); + } + + /// <summary> + /// Produces a value with the magnitude of _X and the sign of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a value with the magnitude of _X and the sign of _Y + /// </returns> + inline float copysign(float _X, float _Y) __GPU_ONLY + { + return __dp_math_copysignf(_X, _Y); + } + + /// <summary> + /// Produces a value with the magnitude of _X and the sign of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a value with the magnitude of _X and the sign of _Y + /// </returns> + inline double copysign(double _X, double _Y) __GPU_ONLY + { + return __dp_math_copysign(_X, _Y); + } + + /// <summary> + /// Calculates the cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of the argument + /// </returns> + inline float cosf(float _X) __GPU_ONLY + { + return __dp_math_cosf(_X); + } + + /// <summary> + /// Calculates the cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of the argument + /// </returns> + inline float cos(float _X) __GPU_ONLY + { + return __dp_math_cosf(_X); + } + + /// <summary> + /// Calculates the cosine of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of the argument + /// </returns> + inline double cos(double _X) __GPU_ONLY + { + return __dp_math_cos(_X); + } + + /// <summary> + /// Calculates the hyperbolic cosine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic cosine value of the argument + /// </returns> + inline float coshf(float _X) __GPU_ONLY + { + return __dp_math_coshf(_X); + } + + /// <summary> + /// Calculates the hyperbolic cosine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic cosine value of the argument + /// </returns> + inline float cosh(float _X) __GPU_ONLY + { + return __dp_math_coshf(_X); + } + + /// <summary> + /// Calculates the hyperbolic cosine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic cosine value of the argument + /// </returns> + inline double cosh(double _X) __GPU_ONLY + { + return __dp_math_cosh(_X); + } + + /// <summary> + /// Calculates the cosine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of pi * _X + /// </returns> + inline float cospif(float _X) __GPU_ONLY + { + return __dp_math_cospif(_X); + } + + /// <summary> + /// Calculates the cosine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of pi * _X + /// </returns> + inline float cospi(float _X) __GPU_ONLY + { + return __dp_math_cospif(_X); + } + + /// <summary> + /// Calculates the cosine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cosine value of pi * _X + /// </returns> + inline double cospi(double _X) __GPU_ONLY + { + return __dp_math_cospi(_X); + } + + /// <summary> + /// Computes the error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the error function of _X + /// </returns> + inline float erff(float _X) __GPU_ONLY + { + return __dp_math_erff(_X); + } + + /// <summary> + /// Computes the error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the error function of _X + /// </returns> + inline float erf(float _X) __GPU_ONLY + { + return __dp_math_erff(_X); + } + + /// <summary> + /// Computes the error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the error function of _X + /// </returns> + inline double erf(double _X) __GPU_ONLY + { + return __dp_math_erf(_X); + } + + /// <summary> + /// Computes the complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the complementary error function of _X + /// </returns> + inline float erfcf(float _X) __GPU_ONLY + { + return __dp_math_erfcf(_X); + } + + /// <summary> + /// Computes the complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the complementary error function of _X + /// </returns> + inline float erfc(float _X) __GPU_ONLY + { + return __dp_math_erfcf(_X); + } + + /// <summary> + /// Computes the complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the complementary error function of _X + /// </returns> + inline double erfc(double _X) __GPU_ONLY + { + return __dp_math_erfc(_X); + } + + /// <summary> + /// Computes the inverse error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse error function of _X + /// </returns> + inline float erfinvf(float _X) __GPU_ONLY + { + return __dp_math_erfinvf(_X); + } + + /// <summary> + /// Computes the inverse error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse error function of _X + /// </returns> + inline float erfinv(float _X) __GPU_ONLY + { + return __dp_math_erfinvf(_X); + } + + /// <summary> + /// Computes the inverse error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse error function of _X + /// </returns> + inline double erfinv(double _X) __GPU_ONLY + { + return __dp_math_erfinv(_X); + } + + /// <summary> + /// Computes the inverse complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse complementary error function of _X + /// </returns> + inline float erfcinvf(float _X) __GPU_ONLY + { + return __dp_math_erfcinvf(_X); + } + + /// <summary> + /// Computes the inverse complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse complementary error function of _X + /// </returns> + inline float erfcinv(float _X) __GPU_ONLY + { + return __dp_math_erfcinvf(_X); + } + + /// <summary> + /// Computes the inverse complementary error function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse complementary error function of _X + /// </returns> + inline double erfcinv(double _X) __GPU_ONLY + { + return __dp_math_erfcinv(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument + /// </returns> + inline float expf(float _X) __GPU_ONLY + { + return __dp_math_expf(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument + /// </returns> + inline float exp(float _X) __GPU_ONLY + { + return __dp_math_expf(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument + /// </returns> + inline double exp(double _X) __GPU_ONLY + { + return __dp_math_exp(_X); + } + + /// <summary> + /// Calculates the base-2 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 exponential of the argument + /// </returns> + inline float exp2f(float _X) __GPU_ONLY + { + return __dp_math_exp2f(_X); + } + + /// <summary> + /// Calculates the base-2 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 exponential of the argument + /// </returns> + inline float exp2(float _X) __GPU_ONLY + { + return __dp_math_exp2f(_X); + } + + /// <summary> + /// Calculates the base-2 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-2 exponential of the argument + /// </returns> + inline double exp2(double _X) __GPU_ONLY + { + return __dp_math_exp2(_X); + } + + /// <summary> + /// Calculates the base-10 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 exponential of the argument + /// </returns> + inline float exp10f(float _X) __GPU_ONLY + { + return __dp_math_exp10f(_X); + } + + /// <summary> + /// Calculates the base-10 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 exponential of the argument + /// </returns> + inline float exp10(float _X) __GPU_ONLY + { + return __dp_math_exp10f(_X); + } + + /// <summary> + /// Calculates the base-10 exponential of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 exponential of the argument + /// </returns> + inline double exp10(double _X) __GPU_ONLY + { + return __dp_math_exp10(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument, minus 1 + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument, minus 1 + /// </returns> + inline float expm1f(float _X) __GPU_ONLY + { + return __dp_math_expm1f(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument, minus 1 + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument, minus 1 + /// </returns> + inline float expm1(float _X) __GPU_ONLY + { + return __dp_math_expm1f(_X); + } + + /// <summary> + /// Calculates the base-e exponential of the argument, minus 1 + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e exponential of the argument, minus 1 + /// </returns> + inline double expm1(double _X) __GPU_ONLY + { + return __dp_math_expm1(_X); + } + + /// <summary> + /// Returns the absolute value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the absolute value of the argument + /// </returns> + inline float fabsf(float _X) __GPU_ONLY + { + return __dp_math_fabsf(_X); + } + + /// <summary> + /// Returns the absolute value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the absolute value of the argument + /// </returns> + inline float fabs(float _X) __GPU_ONLY + { + return __dp_math_fabsf(_X); + } + + /// <summary> + /// Returns the absolute value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the absolute value of the argument + /// </returns> + inline double fabs(double _X) __GPU_ONLY + { + return __dp_math_fabs(_X); + } + + /// <summary> + /// Determines the positive difference between the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X - _Y if _X > _Y; +0, otherwise + /// </returns> + inline float fdimf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fdimf(_X, _Y); + } + + + /// <summary> + /// Determines the positive difference between the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X - _Y if _X > _Y; +0, otherwise + /// </returns> + inline float fdim(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fdimf(_X, _Y); + } + + + /// <summary> + /// Determines the positive difference between the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X - _Y if _X > _Y; +0, otherwise + /// </returns> + inline double fdim(double _X, double _Y) __GPU_ONLY + { + return __dp_math_fdim(_X, _Y); + } + + /// <summary> + /// Calculates the floor of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floor of the argument + /// </returns> + inline float floorf(float _X) __GPU_ONLY + { + return __dp_math_floorf(_X); + } + + /// <summary> + /// Calculates the floor of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floor of the argument + /// </returns> + inline float floor(float _X) __GPU_ONLY + { + return __dp_math_floorf(_X); + } + + /// <summary> + /// Calculates the floor of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floor of the argument + /// </returns> + inline double floor(double _X) __GPU_ONLY + { + return __dp_math_floor(_X); + } + + /// <summary> + /// Compute (_X * _Y) + _Z, rounded as one ternary operation + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Z"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns (_X * _Y) + _Z, rounded as one ternary operation + /// </returns> + inline float fmaf(float _X, float _Y, float _Z) __GPU_ONLY + { + return __dp_math_fmaf(_X, _Y, _Z); + } + + /// <summary> + /// Compute (_X * _Y) + _Z, rounded as one ternary operation + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Z"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns (_X * _Y) + _Z, rounded as one ternary operation + /// </returns> + inline float fma(float _X, float _Y, float _Z) __GPU_ONLY + { + return __dp_math_fmaf(_X, _Y, _Z); + } + + /// <summary> + /// Compute (_X * _Y) + _Z, rounded as one ternary operation + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Z"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns (_X * _Y) + _Z, rounded as one ternary operation + /// </returns> + inline double fma(double _X, double _Y, double _Z) __GPU_ONLY + { + return __dp_math_fma(_X, _Y, _Z); + } + + /// <summary> + /// Determine the maximum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the maximum numeric value of the arguments + /// </returns> + inline float fmaxf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fmaxf(_X, _Y); + } + + /// <summary> + /// Determine the maximum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the maximum numeric value of the arguments + /// </returns> + inline float fmax(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fmaxf(_X, _Y); + } + + /// <summary> + /// Determine the maximum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the maximum numeric value of the arguments + /// </returns> + inline double fmax(double _X, double _Y) __GPU_ONLY + { + return __dp_math_fmax(_X, _Y); + } + + /// <summary> + /// Determine the minimum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the minimum numeric value of the arguments + /// </returns> + inline float fminf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fminf(_X, _Y); + } + + /// <summary> + /// Determine the minimum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the minimum numeric value of the arguments + /// </returns> + inline float fmin(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fminf(_X, _Y); + } + + /// <summary> + /// Determine the minimum numeric value of the arguments + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Return the minimum numeric value of the arguments + /// </returns> + inline double fmin(double _X, double _Y) __GPU_ONLY + { + return __dp_math_fmin(_X, _Y); + } + + /// <summary> + /// Calculates the floating-point remainder of _X/_Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floating-point remainder of _X/_Y + /// </returns> + inline float fmodf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fmodf(_X, _Y); + } + + /// <summary> + /// Calculates the floating-point remainder of _X/_Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floating-point remainder of _X/_Y + /// </returns> + inline float fmod(float _X, float _Y) __GPU_ONLY + { + return __dp_math_fmodf(_X, _Y); + } + + /// <summary> + /// Calculates the floating-point remainder of _X/_Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the floating-point remainder of _X/_Y + /// </returns> + inline double fmod(double _X, double _Y) __GPU_ONLY + { + return __dp_math_fmod(_X, _Y); + } + + + /// <summary> + /// Classifies the argument value as NaN, infinite, normal, subnormal, zero + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the value of the number classification macro appropriate to the value of the argument. + /// </returns> + inline int fpclassify(float _X) __GPU_ONLY + { + return __dp_math_fpclassifyf(_X); + } + + /// <summary> + /// Classifies the argument value as NaN, infinite, normal, subnormal, zero + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the value of the number classification macro appropriate to the value of the argument. + /// </returns> + inline int fpclassify(double _X) __GPU_ONLY + { + return __dp_math_fpclassify(_X); + } + + /// <summary> + /// Gets the mantissa and exponent of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Exp"> + /// Returns the integer exponent of _X in floating-point value + /// </param> + /// <returns> + /// Returns the mantissa _X + /// </returns> + inline float frexpf(float _X, _Out_ int * _Exp) __GPU_ONLY + { + return __dp_math_frexpf(_X, _Exp); + } + + /// <summary> + /// Gets the mantissa and exponent of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Exp"> + /// Returns the integer exponent of _X in floating-point value + /// </param> + /// <returns> + /// Returns the mantissa _X + /// </returns> + inline float frexp(float _X, _Out_ int * _Exp) __GPU_ONLY + { + return __dp_math_frexpf(_X, _Exp); + } + + /// <summary> + /// Gets the mantissa and exponent of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Exp"> + /// Returns the integer exponent of _X in floating-point value + /// </param> + /// <returns> + /// Returns the mantissa _X + /// </returns> + inline double frexp(double _X, _Out_ int * _Exp) __GPU_ONLY + { + return __dp_math_frexp(_X, _Exp); + } + + /// <summary> + /// Computes the square root of the sum of the squares of _X and _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the square root of the sum of the squares of _X and _Y + /// </returns> + inline float hypotf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_hypotf(_X, _Y); + } + + /// <summary> + /// Computes the square root of the sum of the squares of _X and _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the square root of the sum of the squares of _X and _Y + /// </returns> + inline float hypot(float _X, float _Y) __GPU_ONLY + { + return __dp_math_hypotf(_X, _Y); + } + + /// <summary> + /// Computes the square root of the sum of the squares of _X and _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the square root of the sum of the squares of _X and _Y + /// </returns> + inline double hypot(double _X, double _Y) __GPU_ONLY + { + return __dp_math_hypot(_X, _Y); + } + + /// <summary> + /// Extract the exponent of _X as a signed int value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the exponent of _X as a signed int value + /// </returns> + inline int ilogbf(float _X) __GPU_ONLY + { + return __dp_math_ilogbf(_X); + } + + /// <summary> + /// Extract the exponent of _X as a signed int value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the exponent of _X as a signed int value + /// </returns> + inline int ilogb(float _X) __GPU_ONLY + { + return __dp_math_ilogbf(_X); + } + + /// <summary> + /// Extract the exponent of _X as a signed int value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the exponent of _X as a signed int value + /// </returns> + inline int ilogb(double _X) __GPU_ONLY + { + return __dp_math_ilogb(_X); + } + + /// <summary> + /// Determines whether the argument has a finite value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a finite value + /// </returns> + inline int isfinite(float _X) __GPU_ONLY + { + return __dp_math_isfinitef(_X); + } + + /// <summary> + /// Determines whether the argument has a finite value + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a finite value + /// </returns> + inline int isfinite(double _X) __GPU_ONLY + { + return __dp_math_isfinite(_X); + } + + /// <summary> + /// Determines whether the argument is an infinity + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has an infinite value + /// </returns> + inline int isinf(float _X) __GPU_ONLY + { + return __dp_math_isinff(_X); + } + + /// <summary> + /// Determines whether the argument is an infinity + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has an infinite value + /// </returns> + inline int isinf(double _X) __GPU_ONLY + { + return __dp_math_isinf(_X); + } + + /// <summary> + /// Determines whether the argument is a NaN + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a NaN value + /// </returns> + inline int isnan(float _X) __GPU_ONLY + { + return __dp_math_isnanf(_X); + } + + /// <summary> + /// Determines whether the argument is a NaN + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a NaN value + /// </returns> + inline int isnan(double _X) __GPU_ONLY + { + return __dp_math_isnan(_X); + } + + /// <summary> + /// Determines whether the argument is a normal + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a normal value + /// </returns> + inline int isnormal(float _X) __GPU_ONLY + { + return __dp_math_isnormalf(_X); + } + + /// <summary> + /// Determines whether the argument is a normal + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the argument has a normal value + /// </returns> + inline int isnormal(double _X) __GPU_ONLY + { + return __dp_math_isnormal(_X); + } + + /// <summary> + /// Computes a real number from the mantissa and exponent + /// </summary> + /// <param name="_X"> + /// Floating-point value, mantissa + /// </param> + /// <param name="_Exp"> + /// Integer value, exponent + /// </param> + /// <returns> + /// Returns _X * 2^_Exp + /// </returns> + inline float ldexpf(float _X, int _Exp) __GPU_ONLY + { + return __dp_math_ldexpf(_X, _Exp); + } + + /// <summary> + /// Computes a real number from the mantissa and exponent + /// </summary> + /// <param name="_X"> + /// Floating-point value, mantissa + /// </param> + /// <param name="_Exp"> + /// Integer value, exponent + /// </param> + /// <returns> + /// Returns _X * 2^_Exp + /// </returns> + inline float ldexp(float _X, int _Exp) __GPU_ONLY + { + return __dp_math_ldexpf(_X, _Exp); + } + + /// <summary> + /// Computes a real number from the mantissa and exponent + /// </summary> + /// <param name="_X"> + /// Floating-point value, mantissa + /// </param> + /// <param name="_Exp"> + /// Integer value, exponent + /// </param> + /// <returns> + /// Returns _X * 2^_Exp + /// </returns> + inline double ldexp(double _X, int _Exp) __GPU_ONLY + { + return __dp_math_ldexp(_X, _Exp); + } + + /// <summary> + /// Computes the natural logarithm of the absolute value of gamma of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Sign"> + /// Returns the sign + /// </param> + /// <returns> + /// Returns the natural logarithm of the absolute value of gamma of the argument + /// </returns> + inline float lgammaf(float _X, _Out_ int * _Sign) __GPU_ONLY + { + return __dp_math_lgammaf(_X, _Sign); + } + + /// <summary> + /// Computes the natural logarithm of the absolute value of gamma of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Sign"> + /// Returns the sign + /// </param> + /// <returns> + /// Returns the natural logarithm of the absolute value of gamma of the argument + /// </returns> + inline float lgamma(float _X, _Out_ int * _Sign) __GPU_ONLY + { + return __dp_math_lgammaf(_X, _Sign); + } + + /// <summary> + /// Computes the natural logarithm of the absolute value of gamma of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Sign"> + /// Returns the sign + /// </param> + /// <returns> + /// Returns the natural logarithm of the absolute value of gamma of the argument + /// </returns> + inline double lgamma(double _X, _Out_ int * _Sign) __GPU_ONLY + { + return __dp_math_lgamma(_X, _Sign); + } + + /// <summary> + /// Calculates the base-e logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of the argument + /// </returns> + inline float logf(float _X) __GPU_ONLY + { + return __dp_math_logf(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of the argument + /// </returns> + inline float log(float _X) __GPU_ONLY + { + return __dp_math_logf(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of the argument + /// </returns> + inline double log(double _X) __GPU_ONLY + { + return __dp_math_log(_X); + } + + /// <summary> + /// Calculates the base-10 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log10f(float _X) __GPU_ONLY + { + return __dp_math_log10f(_X); + } + + /// <summary> + /// Calculates the base-10 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log10(float _X) __GPU_ONLY + { + return __dp_math_log10f(_X); + } + + /// <summary> + /// Calculates the base-10 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline double log10(double _X) __GPU_ONLY + { + return __dp_math_log10(_X); + } + + /// <summary> + /// Calculates the base-2 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log2f(float _X) __GPU_ONLY + { + return __dp_math_log2f(_X); + } + + /// <summary> + /// Calculates the base-2 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline float log2(float _X) __GPU_ONLY + { + return __dp_math_log2f(_X); + } + + /// <summary> + /// Calculates the base-2 logarithm of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-10 logarithm of the argument + /// </returns> + inline double log2(double _X) __GPU_ONLY + { + return __dp_math_log2(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of 1 plus the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of 1 plus the argument + /// </returns> + inline float log1pf(float _X) __GPU_ONLY + { + return __dp_math_log1pf(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of 1 plus the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of 1 plus the argument + /// </returns> + inline float log1p(float _X) __GPU_ONLY + { + return __dp_math_log1pf(_X); + } + + /// <summary> + /// Calculates the base-e logarithm of 1 plus the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the base-e logarithm of 1 plus the argument + /// </returns> + inline double log1p(double _X) __GPU_ONLY + { + return __dp_math_log1p(_X); + } + + /// <summary> + /// Extracts the exponent of _X, as a signed integer value in floating-point format + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the signed exponent of _X + /// </returns> + inline float logbf(float _X) __GPU_ONLY + { + return __dp_math_logbf(_X); + } + + /// <summary> + /// Extracts the exponent of _X, as a signed integer value in floating-point format + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the signed exponent of _X + /// </returns> + inline float logb(float _X) __GPU_ONLY + { + return __dp_math_logbf(_X); + } + + /// <summary> + /// Extracts the exponent of _X, as a signed integer value in floating-point format + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the signed exponent of _X + /// </returns> + inline double logb(double _X) __GPU_ONLY + { + return __dp_math_logb(_X); + } + + /// <summary> + /// Splits _X into fractional and integer parts. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Iptr"> + /// Returns the integer portion of _X in floating-point value + /// </param> + /// <returns> + /// Returns the signed fractional portion of _X + /// </returns> + inline float modff(float _X, _Out_ float * _Iptr) __GPU_ONLY + { + return __dp_math_modff(_X, _Iptr); + } + + /// <summary> + /// Splits _X into fractional and integer parts. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Iptr"> + /// Returns the integer portion of _X in floating-point value + /// </param> + /// <returns> + /// Returns the signed fractional portion of _X + /// </returns> + inline float modf(float _X, _Out_ float * _Iptr) __GPU_ONLY + { + return __dp_math_modff(_X, _Iptr); + } + + /// <summary> + /// Splits _X into fractional and integer parts. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Iptr"> + /// Returns the integer portion of _X in floating-point value + /// </param> + /// <returns> + /// Returns the signed fractional portion of _X + /// </returns> + inline double modf(double _X, _Out_ double * _Iptr) __GPU_ONLY + { + return __dp_math_modf(_X, _Iptr); + } + + /// <summary> + /// Returns a quiet NaN + /// </summary> + /// <param name="_X"> + /// Integer value + /// </param> + /// <returns> + /// Returns a quiet NaN, if available, with the content indicated in _X + /// </returns> + inline float nanf(int _X) __GPU_ONLY + { + return __dp_math_nanf(_X); + } + + /// <summary> + /// Returns a quiet NaN + /// </summary> + /// <param name="_X"> + /// Integer value + /// </param> + /// <returns> + /// Returns a quiet NaN, if available, with the content indicated in _X + /// </returns> + inline double nan(int _X) __GPU_ONLY + { + return __dp_math_nan(_X); + } + + + /// <summary> + /// Rounds the argument to an integer value in + /// floating-point format, using the current rounding direction. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the rounded integer value. + /// </returns> + inline float nearbyintf(float _X) __GPU_ONLY + { + return __dp_math_nearbyintf(_X); + } + + /// <summary> + /// Rounds the argument to an integer value in + /// floating-point format, using the current rounding direction. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the rounded integer value. + /// </returns> + inline float nearbyint(float _X) __GPU_ONLY + { + return __dp_math_nearbyintf(_X); + } + + /// <summary> + /// Rounds the argument to an integer value in + /// floating-point format, using the current rounding direction. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the rounded integer value. + /// </returns> + inline double nearbyint(double _X) __GPU_ONLY + { + return __dp_math_nearbyint(_X); + } + + + /// <summary> + /// Determine the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returnsthe the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </returns> + inline float nextafterf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_nextafterf(_X, _Y); + } + + /// <summary> + /// Determine the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returnsthe the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </returns> + inline float nextafter(float _X, float _Y) __GPU_ONLY + { + return __dp_math_nextafterf(_X, _Y); + } + + /// <summary> + /// Determine the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returnsthe the next representable value, in the type of the function, + /// after _X in the direction of _Y + /// </returns> + inline double nextafter(double _X, double _Y) __GPU_ONLY + { + return __dp_math_nextafter(_X, _Y); + } + + /// <summary> + /// Returns the cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cumulative distribution function of the argument + /// </returns> + inline float phif(float _X) __GPU_ONLY + { + return __dp_math_phif(_X); + } + + /// <summary> + /// Returns the cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cumulative distribution function of the argument + /// </returns> + inline float phi(float _X) __GPU_ONLY + { + return __dp_math_phif(_X); + } + + /// <summary> + /// Returns the cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the cumulative distribution function of the argument + /// </returns> + inline double phi(double _X) __GPU_ONLY + { + return __dp_math_phi(_X); + } + + /// <summary> + /// Calculates _X raised to the power of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value, base + /// </param> + /// <param name="_Y"> + /// Floating-point value, exponent + /// </param> + /// <returns> + /// Returns the value of _X raised to the power of _Y + /// </returns> + inline float powf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_powf(_X, _Y); + } + + /// <summary> + /// Calculates _X raised to the power of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value, base + /// </param> + /// <param name="_Y"> + /// Floating-point value, exponent + /// </param> + /// <returns> + /// Returns the value of _X raised to the power of _Y + /// </returns> + inline float pow(float _X, float _Y) __GPU_ONLY + { + return __dp_math_powf(_X, _Y); + } + + /// <summary> + /// Calculates _X raised to the power of _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value, base + /// </param> + /// <param name="_Y"> + /// Floating-point value, exponent + /// </param> + /// <returns> + /// Returns the value of _X raised to the power of _Y + /// </returns> + inline double pow(double _X, double _Y) __GPU_ONLY + { + return __dp_math_pow(_X, _Y); + } + + + /// <summary> + /// Returns the inverse cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse cumulative distribution function of the argument + /// </returns> + inline float probitf(float _X) __GPU_ONLY + { + return __dp_math_probitf(_X); + } + + /// <summary> + /// Returns the inverse cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse cumulative distribution function of the argument + /// </returns> + inline float probit(float _X) __GPU_ONLY + { + return __dp_math_probitf(_X); + } + + /// <summary> + /// Returns the inverse cumulative distribution function of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the inverse cumulative distribution function of the argument + /// </returns> + inline double probit(double _X) __GPU_ONLY + { + return __dp_math_probit(_X); + } + + /// <summary> + /// Returns the reciprocal of the cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the cube root of the argument + /// </returns> + inline float rcbrtf(float _X) __GPU_ONLY + { + return __dp_math_rcbrtf(_X); + } + + /// <summary> + /// Returns the reciprocal of the cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the cube root of the argument + /// </returns> + inline float rcbrt(float _X) __GPU_ONLY + { + return __dp_math_rcbrtf(_X); + } + + /// <summary> + /// Returns the reciprocal of the cube root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the cube root of the argument + /// </returns> + inline double rcbrt(double _X) __GPU_ONLY + { + return __dp_math_rcbrt(_X); + } + + /// <summary> + /// Computes the remainder: _X REM _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X REM _Y + /// </returns> + inline float remainderf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_remainderf(_X, _Y); + } + + /// <summary> + /// Computes the remainder: _X REM _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X REM _Y + /// </returns> + inline float remainder(float _X, float _Y) __GPU_ONLY + { + return __dp_math_remainderf(_X, _Y); + } + + /// <summary> + /// Computes the remainder: _X REM _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X REM _Y + /// </returns> + inline double remainder(double _X, double _Y) __GPU_ONLY + { + return __dp_math_remainder(_X, _Y); + } + + /// <summary> + /// Computes the same remainder as _X REM _Y. Also calculates + /// the lower 24 bits of the integral quotient _X/_Y, and + /// gives that value the same sign as _X/_Y. It stores this + /// signed value in the integer pointed to by _Quo. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Quo"> + /// Pointer to an integer value + /// </param> + /// <returns> + /// Returns the remainder + /// </returns> + inline float remquof(float _X, float _Y, _Out_ int * _Quo) __GPU_ONLY + { + return __dp_math_remquof(_X, _Y, _Quo); + } + + /// <summary> + /// Computes the same remainder as _X REM _Y. Also calculates + /// the lower 24 bits of the integral quotient _X/_Y, and + /// gives that value the same sign as _X/_Y. It stores this + /// signed value in the integer pointed to by _Quo. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Quo"> + /// Pointer to an integer value + /// </param> + /// <returns> + /// Returns the remainder + /// </returns> + inline float remquo(float _X, float _Y, _Out_ int * _Quo) __GPU_ONLY + { + return __dp_math_remquof(_X, _Y, _Quo); + } + + /// <summary> + /// Computes the same remainder as _X REM _Y. Also calculates + /// the lower 31 bits of the integral quotient _X/_Y, and + /// gives that value the same sign as _X/_Y. It stores this + /// signed value in the integer pointed to by _Quo. + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <param name="_Quo"> + /// Pointer to an integer value + /// </param> + /// <returns> + /// Returns the remainder + /// </returns> + inline double remquo(double _X, double _Y, _Out_ int * _Quo) __GPU_ONLY + { + return __dp_math_remquo(_X, _Y, _Quo); + } + + /// <summary> + /// Rounds _X to the nearest integer + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the nearest integer of _X + /// </returns> + inline float roundf(float _X) __GPU_ONLY + { + return __dp_math_roundf(_X); + } + + /// <summary> + /// Rounds _X to the nearest integer + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the nearest integer of _X + /// </returns> + inline float round(float _X) __GPU_ONLY + { + return __dp_math_roundf(_X); + } + + /// <summary> + /// Rounds _X to the nearest integer + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the nearest integer of _X + /// </returns> + inline double round(double _X) __GPU_ONLY + { + return __dp_math_round(_X); + } + + /// <summary> + /// Returns the reciprocal of the square root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the square root of the argument + /// </returns> + inline float rsqrtf(float _X) __GPU_ONLY + { + return __dp_math_rsqrtf(_X); + } + + /// <summary> + /// Returns the reciprocal of the square root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the square root of the argument + /// </returns> + inline float rsqrt(float _X) __GPU_ONLY + { + return __dp_math_rsqrtf(_X); + } + + /// <summary> + /// Returns the reciprocal of the square root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the reciprocal of the square root of the argument + /// </returns> + inline double rsqrt(double _X) __GPU_ONLY + { + return __dp_math_rsqrt(_X); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline float scalbf(float _X, float _Y) __GPU_ONLY + { + return __dp_math_scalbf(_X, _Y); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline float scalb(float _X, float _Y) __GPU_ONLY + { + return __dp_math_scalbf(_X, _Y); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline double scalb(double _X, double _Y) __GPU_ONLY + { + return __dp_math_scalb(_X, _Y); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Integer value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline float scalbnf(float _X, int _Y) __GPU_ONLY + { + return __dp_math_scalbnf(_X, _Y); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Integer value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline float scalbn(float _X, int _Y) __GPU_ONLY + { + return __dp_math_scalbnf(_X, _Y); + } + + /// <summary> + /// Multiplies _X by FLT_RADIX to the power _Y + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_Y"> + /// Integer value + /// </param> + /// <returns> + /// Returns _X * (FLT_RADIX ^ _Y) + /// </returns> + inline double scalbn(double _X, int _Y) __GPU_ONLY + { + return __dp_math_scalbn(_X, _Y); + } + + /// <summary> + /// Determines whether the sign of _X is negative + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the sign of _X + /// is negative + /// </returns> + inline int signbitf(float _X) __GPU_ONLY + { + return __dp_math_signbitf(_X); + } + + /// <summary> + /// Determines whether the sign of _X is negative + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the sign of _X + /// is negative + /// </returns> + inline int signbit(float _X) __GPU_ONLY + { + return __dp_math_signbitf(_X); + } + + /// <summary> + /// Determines whether the sign of _X is negative + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns a nonzero value if and only if the sign of _X + /// is negative + /// </returns> + inline int signbit(double _X) __GPU_ONLY + { + return __dp_math_signbit(_X); + } + + /// <summary> + /// Calculates the sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of the argument + /// </returns> + inline float sinf(float _X) __GPU_ONLY + { + return __dp_math_sinf(_X); + } + + /// <summary> + /// Calculates the sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of the argument + /// </returns> + inline float sin(float _X) __GPU_ONLY + { + return __dp_math_sinf(_X); + } + + /// <summary> + /// Calculates the sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of the argument + /// </returns> + inline double sin(double _X) __GPU_ONLY + { + return __dp_math_sin(_X); + } + + /// <summary> + /// Calculates sine and cosine value of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_S"> + /// Returns the sine value of _X + /// </param> + /// <param name="_C"> + /// Returns the cosine value of _X + /// </param> + inline void sincosf(float _X, _Out_ float * _S, _Out_ float * _C) __GPU_ONLY + { + *_C = __dp_math_sincosf(_X, _S); + } + + /// <summary> + /// Calculates sine and cosine value of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_S"> + /// Returns the sine value of _X + /// </param> + /// <param name="_C"> + /// Returns the cosine value of _X + /// </param> + inline void sincos(float _X, _Out_ float * _S, _Out_ float * _C) __GPU_ONLY + { + *_C = __dp_math_sincosf(_X, _S); + } + + /// <summary> + /// Calculates sine and cosine value of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <param name="_S"> + /// Returns the sine value of _X + /// </param> + /// <param name="_C"> + /// Returns the cosine value of _X + /// </param> + inline void sincos(double _X, _Out_ double * _S, _Out_ double * _C) __GPU_ONLY + { + *_C = __dp_math_sincos(_X, _S); + } + + /// <summary> + /// Calculates the hyperbolic sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic sine value of the argument + /// </returns> + inline float sinhf(float _X) __GPU_ONLY + { + return __dp_math_sinhf(_X); + } + + /// <summary> + /// Calculates the hyperbolic sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic sine value of the argument + /// </returns> + inline float sinh(float _X) __GPU_ONLY + { + return __dp_math_sinhf(_X); + } + + /// <summary> + /// Calculates the hyperbolic sine value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic sine value of the argument + /// </returns> + inline double sinh(double _X) __GPU_ONLY + { + return __dp_math_sinh(_X); + } + + /// <summary> + /// Calculates the sine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of pi * _X + /// </returns> + inline float sinpif(float _X) __GPU_ONLY + { + return __dp_math_sinpif(_X); + } + + /// <summary> + /// Calculates the sine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of pi * _X + /// </returns> + inline float sinpi(float _X) __GPU_ONLY + { + return __dp_math_sinpif(_X); + } + + /// <summary> + /// Calculates the sine value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the sine value of pi * _X + /// </returns> + inline double sinpi(double _X) __GPU_ONLY + { + return __dp_math_sinpi(_X); + } + + /// <summary> + /// Calculates the squre root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the squre root of the argument + /// </returns> + inline float sqrtf(float _X) __GPU_ONLY + { + return __dp_math_sqrtf(_X); + } + + /// <summary> + /// Calculates the squre root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the squre root of the argument + /// </returns> + inline float sqrt(float _X) __GPU_ONLY + { + return __dp_math_sqrtf(_X); + } + + /// <summary> + /// Calculates the squre root of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the squre root of the argument + /// </returns> + inline double sqrt(double _X) __GPU_ONLY + { + return __dp_math_sqrt(_X); + } + + /// <summary> + /// Computes the gamma function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the result of gamma function of _X + /// </returns> + inline float tgammaf(float _X) __GPU_ONLY + { + return __dp_math_tgammaf(_X); + } + + /// <summary> + /// Computes the gamma function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the result of gamma function of _X + /// </returns> + inline float tgamma(float _X) __GPU_ONLY + { + return __dp_math_tgammaf(_X); + } + + /// <summary> + /// Computes the gamma function of _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the result of gamma function of _X + /// </returns> + inline double tgamma(double _X) __GPU_ONLY + { + return __dp_math_tgamma(_X); + } + + /// <summary> + /// Calculates the tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of the argument + /// </returns> + inline float tanf(float _X) __GPU_ONLY + { + return __dp_math_tanf(_X); + } + + /// <summary> + /// Calculates the tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of the argument + /// </returns> + inline float tan(float _X) __GPU_ONLY + { + return __dp_math_tanf(_X); + } + + /// <summary> + /// Calculates the tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of the argument + /// </returns> + inline double tan(double _X) __GPU_ONLY + { + return __dp_math_tan(_X); + } + + /// <summary> + /// Calculates the hyperbolic tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic tangent value of the argument + /// </returns> + inline float tanhf(float _X) __GPU_ONLY + { + return __dp_math_tanhf(_X); + } + + /// <summary> + /// Calculates the hyperbolic tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic tangent value of the argument + /// </returns> + inline float tanh(float _X) __GPU_ONLY + { + return __dp_math_tanhf(_X); + } + + /// <summary> + /// Calculates the hyperbolic tangent value of the argument + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the hyperbolic tangent value of the argument + /// </returns> + inline double tanh(double _X) __GPU_ONLY + { + return __dp_math_tanh(_X); + } + + /// <summary> + /// Calculates the tangent value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of pi * _X + /// </returns> + inline float tanpif(float _X) __GPU_ONLY + { + return __dp_math_tanpif(_X); + } + + /// <summary> + /// Calculates the tangent value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of pi * _X + /// </returns> + inline float tanpi(float _X) __GPU_ONLY + { + return __dp_math_tanpif(_X); + } + + /// <summary> + /// Calculates the tangent value of pi * _X + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the tangent value of pi * _X + /// </returns> + inline double tanpi(double _X) __GPU_ONLY + { + return __dp_math_tanpi(_X); + } + + /// <summary> + /// Truncates the argument to the integer component + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the integer component of the argument + /// </returns> + inline float truncf(float _X) __GPU_ONLY + { + return __dp_math_truncf(_X); + } + + /// <summary> + /// Truncates the argument to the integer component + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the integer component of the argument + /// </returns> + inline float trunc(float _X) __GPU_ONLY + { + return __dp_math_truncf(_X); + } + + /// <summary> + /// Truncates the argument to the integer component + /// </summary> + /// <param name="_X"> + /// Floating-point value + /// </param> + /// <returns> + /// Returns the integer component of the argument + /// </returns> + inline double trunc(double _X) __GPU_ONLY + { + return __dp_math_trunc(_X); + } + + //============================================================================= + // Import CMATH C++ functions: + //============================================================================= + using std::acosf; + using std::asinf; + using std::atanf; + using std::atan2f; + using std::ceilf; + using std::cosf; + using std::coshf; + using std::expf; + using std::fabsf; + using std::floorf; + using std::fmodf; + using std::frexpf; + using std::hypotf; + using std::ldexpf; + using std::logf; + using std::log10f; + using std::modff; + using std::powf; + using std::sinf; + using std::sinhf; + using std::sqrtf; + using std::tanf; + using std::tanhf; + + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::hypot; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + + using std::acosh; + using std::acoshf; + using std::asinh; + using std::asinhf; + using std::atanh; + using std::atanhf; + using std::cbrt; + using std::cbrtf; + using std::copysign; + using std::copysignf; + using std::erf; + using std::erfc; + using std::erfcf; + using std::erff; + using std::exp2; + using std::exp2f; + using std::expm1; + using std::expm1f; + using std::fdim; + using std::fdimf; + using std::fma; + using std::fmaf; + using std::fmax; + using std::fmaxf; + using std::fmin; + using std::fminf; + using std::ilogb; + using std::ilogbf; + using std::log1p; + using std::log1pf; + using std::log2; + using std::log2f; + using std::logb; + using std::logbf; + using std::nearbyint; + using std::nearbyintf; + using std::nextafter; + using std::nextafterf; + using std::remainder; + using std::remainderf; + using std::remquo; + using std::remquof; + using std::round; + using std::roundf; + using std::scalbn; + using std::scalbnf; + using std::tgamma; + using std::tgammaf; + using std::trunc; + using std::truncf; +} // namespace precise_math + +} // namespace Concurrency diff --git a/test_data/lots_of_files/amp_short_vectors.h b/test_data/lots_of_files/amp_short_vectors.h new file mode 100644 index 0000000..8c65915 --- /dev/null +++ b/test_data/lots_of_files/amp_short_vectors.h @@ -0,0 +1,24178 @@ +/*** +* ==++== +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* ==--== +* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ +* +* amp_short_vectors.h +* +* C++ AMP Short Vector Types +* +* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +****/ + + +// !!! DO NOT HAND EDIT !!! +// This file was generated. + +#pragma once + +#pragma warning(push) +#pragma warning(disable : 4100) +#include <amp.h> +#define _AMP_SHORT_VECTORS_H +namespace Concurrency +{ + namespace graphics + { + class unorm; + class norm; + + /// <summary> + /// Represent a unorm number. + /// Each element is a floating point number in the range of [0.0f, 1.0f]. + /// </summary> + class unorm + { + friend class norm; + private: + float _Value; + void _Set(float _Val) __CPU_ONLY + { + _Val = _Val < 0.0f ? 0.0f : _Val; + _Val = _Val > 1.0f ? 1.0f : _Val; + _Value = _Val; + } + + void _Set(float _Val) __GPU_ONLY + { + _Value = Concurrency::direct3d::clamp(_Val, 0.0f, 1.0f); + } + public: + + /// <summary> + /// Default constructor. Initialize to 0.0f. + /// </summary> + unorm(void) __GPU + { + _Value = 0.0f; + } + + /// <summary> + /// Constructor. Initialize by clamping _V to the range of [0.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit unorm(float _V) __GPU + { + _Set(_V); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [0.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit unorm(unsigned int _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [0.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit unorm(int _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [0.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit unorm(double _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + unorm(const unorm& _Other) __GPU + { + _Value = _Other._Value; + } + + /// <summary> + /// Constructor. Initialize by clamping _Other to the range of [0.0f, 1.0f]. + /// </summary> + /// <param name="_Other"> + /// The norm object used to initialize. + /// </param> + inline explicit unorm(const norm& _Other) __GPU; + + unorm& operator=(const unorm& _Other) __GPU + { + _Value = _Other._Value; + return *this; + } + + /// <summary> + /// Conversion operator. Convert the unorm number to a floating point value. + /// </summary> + operator float(void) const __GPU + { + return _Value; + } + + unorm& operator+=(const unorm& _Other) __GPU + { + float _Res = _Value; + _Res += _Other._Value; + _Set(_Res); + return *this; + } + + unorm& operator-=(const unorm& _Other) __GPU + { + float _Res = _Value; + _Res -= _Other._Value; + _Set(_Res); + return *this; + } + + unorm& operator*=(const unorm& _Other) __GPU + { + float _Res = _Value; + _Res *= _Other._Value; + _Set(_Res); + return *this; + } + + unorm& operator/=(const unorm& _Other) __GPU + { + float _Res = _Value; + _Res /= _Other._Value; + _Set(_Res); + return *this; + } + + unorm& operator++() __GPU + { + float _Res = _Value; + ++_Res; + _Set(_Res); + return *this; + } + + unorm operator++(int) __GPU + { + unorm _Res = *this; + ++(*this); + return _Res; + } + + unorm& operator--() __GPU + { + float _Res = _Value; + --_Res; + _Set(_Res); + return *this; + } + + unorm operator--(int) __GPU + { + unorm _Res = *this; + --(*this); + return _Res; + } + + }; + + /// <summary> + /// Represent a norm number. + /// Each element is a floating point number in the range of [-1.0f, 1.0f]. + /// </summary> + class norm + { + friend class unorm; + private: + float _Value; + void _Set(float _Val) __CPU_ONLY + { + _Val = _Val < -1.0f ? -1.0f : _Val; + _Val = _Val > 1.0f ? 1.0f : _Val; + _Value = _Val; + } + + void _Set(float _Val) __GPU_ONLY + { + _Value = Concurrency::direct3d::clamp(_Val, -1.0f, 1.0f); + } + public: + + /// <summary> + /// Default constructor. Initialize to 0.0f. + /// </summary> + norm(void) __GPU + { + _Value = 0.0f; + } + + /// <summary> + /// Constructor. Initialize by clamping _V to the range of [-1.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit norm(float _V) __GPU + { + _Set(_V); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [-1.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit norm(unsigned int _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [-1.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit norm(int _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Constructor. Initialize by casting _V to float, then clamping to the range of [-1.0f, 1.0f]. + /// </summary> + /// <param name="_V"> + /// The value used to initialize. + /// </param> + explicit norm(double _V) __GPU + { + _Set(static_cast<float>(_V)); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + norm(const norm& _Other) __GPU + { + _Value = _Other._Value; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + norm(const unorm& _Other) __GPU + { + _Value = _Other._Value; + } + + norm& operator=(const norm& _Other) __GPU + { + _Value = _Other._Value; + return *this; + } + + /// <summary> + /// Conversion operator. Convert the norm number to a floating point value. + /// </summary> + operator float(void) const __GPU + { + return _Value; + } + + norm& operator+=(const norm& _Other) __GPU + { + float _Res = _Value; + _Res += _Other._Value; + _Set(_Res); + return *this; + } + + norm& operator-=(const norm& _Other) __GPU + { + float _Res = _Value; + _Res -= _Other._Value; + _Set(_Res); + return *this; + } + + norm& operator*=(const norm& _Other) __GPU + { + float _Res = _Value; + _Res *= _Other._Value; + _Set(_Res); + return *this; + } + + norm& operator/=(const norm& _Other) __GPU + { + float _Res = _Value; + _Res /= _Other._Value; + _Set(_Res); + return *this; + } + + norm& operator++() __GPU + { + float _Res = _Value; + ++_Res; + _Set(_Res); + return *this; + } + + norm operator++(int) __GPU + { + norm _Res = *this; + ++(*this); + return _Res; + } + + norm& operator--() __GPU + { + float _Res = _Value; + --_Res; + _Set(_Res); + return *this; + } + + norm operator--(int) __GPU + { + norm _Res = *this; + --(*this); + return _Res; + } + + norm operator-(void) const __GPU + { + norm _Ret; + _Ret._Value = -_Value; + return _Ret; + } + + }; + + unorm::unorm(const norm& _Other) __GPU + { + _Set(_Other._Value); + } + + inline unorm operator+(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return unorm(float(_Lhs) + float(_Rhs)); + } + + inline norm operator+(const norm& _Lhs, const norm& _Rhs) __GPU + { + return norm(float(_Lhs) + float(_Rhs)); + } + + inline unorm operator-(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return unorm(float(_Lhs) - float(_Rhs)); + } + + inline norm operator-(const norm& _Lhs, const norm& _Rhs) __GPU + { + return norm(float(_Lhs) - float(_Rhs)); + } + + inline unorm operator*(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return unorm(float(_Lhs) * float(_Rhs)); + } + + inline norm operator*(const norm& _Lhs, const norm& _Rhs) __GPU + { + return norm(float(_Lhs) * float(_Rhs)); + } + + inline unorm operator/(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return unorm(float(_Lhs) / float(_Rhs)); + } + + inline norm operator/(const norm& _Lhs, const norm& _Rhs) __GPU + { + return norm(float(_Lhs) / float(_Rhs)); + } + + inline bool operator==(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) == float(_Rhs); + } + + inline bool operator==(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) == float(_Rhs); + } + + inline bool operator!=(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) != float(_Rhs); + } + + inline bool operator!=(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) != float(_Rhs); + } + + inline bool operator>(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) > float(_Rhs); + } + + inline bool operator>(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) > float(_Rhs); + } + + inline bool operator<(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) < float(_Rhs); + } + + inline bool operator<(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) < float(_Rhs); + } + + inline bool operator>=(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) >= float(_Rhs); + } + + inline bool operator>=(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) >= float(_Rhs); + } + + inline bool operator<=(const unorm& _Lhs, const unorm& _Rhs) __GPU + { + return float(_Lhs) <= float(_Rhs); + } + + inline bool operator<=(const norm& _Lhs, const norm& _Rhs) __GPU + { + return float(_Lhs) <= float(_Rhs); + } + +#define UNORM_ZERO ((concurrency::graphics::unorm)0.0f) +#define UNORM_MIN ((concurrency::graphics::unorm)0.0f) +#define UNORM_MAX ((concurrency::graphics::unorm)1.0f) +#define NORM_ZERO ((concurrency::graphics::norm)0.0f) +#define NORM_MIN ((concurrency::graphics::norm)-1.0f) +#define NORM_MAX ((concurrency::graphics::norm)1.0f) + + + typedef unsigned int uint; + // Forward Declarations + class uint_2; + class uint_3; + class uint_4; + class int_2; + class int_3; + class int_4; + class float_2; + class float_3; + class float_4; + class unorm_2; + class unorm_3; + class unorm_4; + class norm_2; + class norm_3; + class norm_4; + class double_2; + class double_3; + class double_4; + + /// <summary> + /// Represent a short vector of 2 unsigned int's. + /// </summary> + class uint_2 + { + public: + typedef unsigned int value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Uint_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this uint_2 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int x; + /// <summary> + /// Property for accessing element 0 of this uint_2 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int r; + + /// <summary> + /// Returns element 0 of this uint_2. + /// </summary> + /// <returns> + /// Element 0 of this uint_2. + /// </returns> + unsigned int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_2. + /// </returns> + unsigned int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_2. + /// </returns> + unsigned int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this uint_2 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_x(unsigned int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this uint_2 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int y; + /// <summary> + /// Property for accessing element 1 of this uint_2 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int g; + + /// <summary> + /// Returns element 1 of this uint_2. + /// </summary> + /// <returns> + /// Element 1 of this uint_2. + /// </returns> + unsigned int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_2. + /// </returns> + unsigned int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_2. + /// </returns> + unsigned int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this uint_2 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_y(unsigned int _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + uint_2() __GPU + { + _M_x = 0; + _M_y = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + uint_2(unsigned int _V0, unsigned int _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + uint_2(unsigned int _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_2(const int_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_2(const float_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_2(const unorm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_2(const norm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_2(const double_2& _Other) __GPU; + + uint_2 operator~() const __GPU + { + uint_2 _Value = *this; + return uint_2(~_Value.x, ~_Value.y); + } + + uint_2& operator++() __GPU + { + uint_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + uint_2 operator++(int) __GPU + { + uint_2 _Result = *this; + ++(*this); + return _Result; + } + + uint_2& operator--() __GPU + { + uint_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + uint_2 operator--(int) __GPU + { + uint_2 _Result = *this; + --(*this); + return _Result; + } + + uint_2& operator+=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator-=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator*=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator/=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator%=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator^=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator|=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator&=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator>>=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + *this = _Value1; + return *this; + } + + uint_2& operator<<=(const uint_2& _Other) __GPU + { + uint_2 _Value1 = *this; + uint_2 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this uint_2 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this uint_2 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 rg; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 1 of this uint_2. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xy() const __GPU { + return uint_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this uint_2 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this uint_2 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this uint_2 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 gr; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 0 of this uint_2. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yx() const __GPU { + return uint_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this uint_2 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + }; + + /// <summary> + /// Represent a short vector of 3 unsigned int's. + /// </summary> + class uint_3 + { + public: + typedef unsigned int value_type; + static const int size = 3; + private: + static const _Short_vector_base_type_id _Base_type_id = _Uint_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + + public: + /// <summary> + /// Property for accessing element 0 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int x; + /// <summary> + /// Property for accessing element 0 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int r; + + /// <summary> + /// Returns element 0 of this uint_3. + /// </summary> + /// <returns> + /// Element 0 of this uint_3. + /// </returns> + unsigned int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_3. + /// </returns> + unsigned int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_3. + /// </returns> + unsigned int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this uint_3 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_x(unsigned int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int y; + /// <summary> + /// Property for accessing element 1 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int g; + + /// <summary> + /// Returns element 1 of this uint_3. + /// </summary> + /// <returns> + /// Element 1 of this uint_3. + /// </returns> + unsigned int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_3. + /// </returns> + unsigned int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_3. + /// </returns> + unsigned int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this uint_3 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_y(unsigned int _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unsigned int z; + /// <summary> + /// Property for accessing element 2 of this uint_3 as an unsigned int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unsigned int b; + + /// <summary> + /// Returns element 2 of this uint_3. + /// </summary> + /// <returns> + /// Element 2 of this uint_3. + /// </returns> + unsigned int get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this uint_3. + /// </returns> + unsigned int& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this uint_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this uint_3. + /// </returns> + unsigned int& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this uint_3 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_z(unsigned int _Value) __GPU + { + _M_z = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + uint_3() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + uint_3(unsigned int _V0, unsigned int _V1, unsigned int _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + uint_3(unsigned int _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_3(const int_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_3(const float_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_3(const unorm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_3(const norm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_3(const double_3& _Other) __GPU; + + uint_3 operator~() const __GPU + { + uint_3 _Value = *this; + return uint_3(~_Value.x, ~_Value.y, ~_Value.z); + } + + uint_3& operator++() __GPU + { + uint_3 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + *this = _Value; + return *this; + } + + uint_3 operator++(int) __GPU + { + uint_3 _Result = *this; + ++(*this); + return _Result; + } + + uint_3& operator--() __GPU + { + uint_3 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + *this = _Value; + return *this; + } + + uint_3 operator--(int) __GPU + { + uint_3 _Result = *this; + --(*this); + return _Result; + } + + uint_3& operator+=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator-=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator*=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator/=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator%=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + _Value1.z %= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator^=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + _Value1.z ^= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator|=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + _Value1.z |= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator&=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + _Value1.z &= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator>>=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + _Value1.z >>= _Value2.z; + *this = _Value1; + return *this; + } + + uint_3& operator<<=(const uint_3& _Other) __GPU + { + uint_3 _Value1 = *this; + uint_3 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + _Value1.z <<= _Value2.z; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 rg; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 1 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xy() const __GPU { + return uint_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) uint_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) uint_2 rb; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 2 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xz() const __GPU { + return uint_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xz(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 gr; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 0 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yx() const __GPU { + return uint_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) uint_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) uint_2 gb; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 2 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yz() const __GPU { + return uint_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yz(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) uint_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) uint_2 br; + + /// <summary> + /// Returns a uint_2 that is composed of element 2, and element 0 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_zx() const __GPU { + return uint_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_zx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) uint_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this uint_3 as a uint_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) uint_2 bg; + + /// <summary> + /// Returns a uint_2 that is composed of element 2, and element 1 of this uint_3. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_zy() const __GPU { + return uint_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this uint_3 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_zy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) uint_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) uint_3 rgb; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 1, and element 2 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xyz() const __GPU { + return uint_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xyz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) uint_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) uint_3 rbg; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 2, and element 1 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xzy() const __GPU { + return uint_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xzy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) uint_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) uint_3 grb; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 0, and element 2 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yxz() const __GPU { + return uint_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yxz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) uint_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) uint_3 gbr; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 2, and element 0 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yzx() const __GPU { + return uint_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yzx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) uint_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) uint_3 brg; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 0, and element 1 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zxy() const __GPU { + return uint_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zxy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) uint_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this uint_3 as a uint_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) uint_3 bgr; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 1, and element 0 of this uint_3. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zyx() const __GPU { + return uint_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this uint_3 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zyx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + }; + + /// <summary> + /// Represent a short vector of 4 unsigned int's. + /// </summary> + class uint_4 + { + public: + typedef unsigned int value_type; + static const int size = 4; + private: + static const _Short_vector_base_type_id _Base_type_id = _Uint_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + value_type _M_w; + + public: + /// <summary> + /// Property for accessing element 0 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int x; + /// <summary> + /// Property for accessing element 0 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unsigned int r; + + /// <summary> + /// Returns element 0 of this uint_4. + /// </summary> + /// <returns> + /// Element 0 of this uint_4. + /// </returns> + unsigned int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_4. + /// </returns> + unsigned int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this uint_4. + /// </returns> + unsigned int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this uint_4 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_x(unsigned int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int y; + /// <summary> + /// Property for accessing element 1 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unsigned int g; + + /// <summary> + /// Returns element 1 of this uint_4. + /// </summary> + /// <returns> + /// Element 1 of this uint_4. + /// </returns> + unsigned int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_4. + /// </returns> + unsigned int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this uint_4. + /// </returns> + unsigned int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this uint_4 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_y(unsigned int _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unsigned int z; + /// <summary> + /// Property for accessing element 2 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unsigned int b; + + /// <summary> + /// Returns element 2 of this uint_4. + /// </summary> + /// <returns> + /// Element 2 of this uint_4. + /// </returns> + unsigned int get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this uint_4. + /// </returns> + unsigned int& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this uint_4. + /// </returns> + unsigned int& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this uint_4 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_z(unsigned int _Value) __GPU + { + _M_z = _Value; + } + + /// <summary> + /// Property for accessing element 3 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) unsigned int w; + /// <summary> + /// Property for accessing element 3 of this uint_4 as an unsigned int. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) unsigned int a; + + /// <summary> + /// Returns element 3 of this uint_4. + /// </summary> + /// <returns> + /// Element 3 of this uint_4. + /// </returns> + unsigned int get_w() const __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this uint_4. + /// </returns> + unsigned int& ref_w() __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this uint_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this uint_4. + /// </returns> + unsigned int& ref_a() __GPU { + return _M_w; + } + + /// <summary> + /// Set element 3 of this uint_4 with an unsigned int. + /// </summary> + /// <param name="_Value"> + /// an unsigned int value. + /// </param> + void set_w(unsigned int _Value) __GPU + { + _M_w = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + uint_4() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + _M_w = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + uint_4(unsigned int _V0, unsigned int _V1, unsigned int _V2, unsigned int _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + uint_4(unsigned int _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + _M_w = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_4(const int_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_4(const float_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_4(const unorm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_4(const norm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline uint_4(const double_4& _Other) __GPU; + + uint_4 operator~() const __GPU + { + uint_4 _Value = *this; + return uint_4(~_Value.x, ~_Value.y, ~_Value.z, ~_Value.w); + } + + uint_4& operator++() __GPU + { + uint_4 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + ++_Value._M_w; + *this = _Value; + return *this; + } + + uint_4 operator++(int) __GPU + { + uint_4 _Result = *this; + ++(*this); + return _Result; + } + + uint_4& operator--() __GPU + { + uint_4 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + --_Value._M_w; + *this = _Value; + return *this; + } + + uint_4 operator--(int) __GPU + { + uint_4 _Result = *this; + --(*this); + return _Result; + } + + uint_4& operator+=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + _Value1.w += _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator-=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + _Value1.w -= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator*=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + _Value1.w *= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator/=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + _Value1.w /= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator%=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + _Value1.z %= _Value2.z; + _Value1.w %= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator^=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + _Value1.z ^= _Value2.z; + _Value1.w ^= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator|=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + _Value1.z |= _Value2.z; + _Value1.w |= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator&=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + _Value1.z &= _Value2.z; + _Value1.w &= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator>>=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + _Value1.z >>= _Value2.z; + _Value1.w >>= _Value2.w; + *this = _Value1; + return *this; + } + + uint_4& operator<<=(const uint_4& _Other) __GPU + { + uint_4 _Value1 = *this; + uint_4 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + _Value1.z <<= _Value2.z; + _Value1.w <<= _Value2.w; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) uint_2 rg; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xy() const __GPU { + return uint_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) uint_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) uint_2 rb; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xz() const __GPU { + return uint_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xz(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) uint_2 xw; + /// <summary> + /// Property for accessing element 0, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) uint_2 ra; + + /// <summary> + /// Returns a uint_2 that is composed of element 0, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_xw() const __GPU { + return uint_2(_M_x,_M_w); + } + + /// <summary> + /// Set element 0, and 3 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_xw(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) uint_2 gr; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yx() const __GPU { + return uint_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) uint_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) uint_2 gb; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yz() const __GPU { + return uint_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yz(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) uint_2 yw; + /// <summary> + /// Property for accessing element 1, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) uint_2 ga; + + /// <summary> + /// Returns a uint_2 that is composed of element 1, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_yw() const __GPU { + return uint_2(_M_y,_M_w); + } + + /// <summary> + /// Set element 1, and 3 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_yw(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) uint_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) uint_2 br; + + /// <summary> + /// Returns a uint_2 that is composed of element 2, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_zx() const __GPU { + return uint_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_zx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) uint_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) uint_2 bg; + + /// <summary> + /// Returns a uint_2 that is composed of element 2, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_zy() const __GPU { + return uint_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_zy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) uint_2 zw; + /// <summary> + /// Property for accessing element 2, and 3 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) uint_2 ba; + + /// <summary> + /// Returns a uint_2 that is composed of element 2, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_zw() const __GPU { + return uint_2(_M_z,_M_w); + } + + /// <summary> + /// Set element 2, and 3 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_zw(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) uint_2 wx; + /// <summary> + /// Property for accessing element 3, and 0 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) uint_2 ar; + + /// <summary> + /// Returns a uint_2 that is composed of element 3, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_wx() const __GPU { + return uint_2(_M_w,_M_x); + } + + /// <summary> + /// Set element 3, and 0 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_wx(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) uint_2 wy; + /// <summary> + /// Property for accessing element 3, and 1 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) uint_2 ag; + + /// <summary> + /// Returns a uint_2 that is composed of element 3, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_wy() const __GPU { + return uint_2(_M_w,_M_y); + } + + /// <summary> + /// Set element 3, and 1 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_wy(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) uint_2 wz; + /// <summary> + /// Property for accessing element 3, and 2 of this uint_4 as a uint_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) uint_2 ab; + + /// <summary> + /// Returns a uint_2 that is composed of element 3, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_2. + /// </returns> + uint_2 get_wz() const __GPU { + return uint_2(_M_w,_M_z); + } + + /// <summary> + /// Set element 3, and 2 of this uint_4 with a uint_2. + /// </summary> + /// <param name="_Value"> + /// a uint_2 value. + /// </param> + void set_wz(const uint_2& _Value) __GPU + { + uint_2 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) uint_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) uint_3 rgb; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 1, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xyz() const __GPU { + return uint_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xyz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) uint_3 xyw; + /// <summary> + /// Property for accessing element 0, 1, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) uint_3 rga; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 1, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xyw() const __GPU { + return uint_3(_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 1, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xyw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) uint_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) uint_3 rbg; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 2, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xzy() const __GPU { + return uint_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xzy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) uint_3 xzw; + /// <summary> + /// Property for accessing element 0, 2, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) uint_3 rba; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 2, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xzw() const __GPU { + return uint_3(_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 2, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xzw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) uint_3 xwy; + /// <summary> + /// Property for accessing element 0, 3, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) uint_3 rag; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 3, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xwy() const __GPU { + return uint_3(_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 3, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xwy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) uint_3 xwz; + /// <summary> + /// Property for accessing element 0, 3, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) uint_3 rab; + + /// <summary> + /// Returns a uint_3 that is composed of element 0, element 3, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_xwz() const __GPU { + return uint_3(_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 3, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_xwz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) uint_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) uint_3 grb; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 0, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yxz() const __GPU { + return uint_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yxz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) uint_3 yxw; + /// <summary> + /// Property for accessing element 1, 0, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) uint_3 gra; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 0, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yxw() const __GPU { + return uint_3(_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 0, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yxw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) uint_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) uint_3 gbr; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 2, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yzx() const __GPU { + return uint_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yzx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) uint_3 yzw; + /// <summary> + /// Property for accessing element 1, 2, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) uint_3 gba; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 2, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_yzw() const __GPU { + return uint_3(_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 2, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_yzw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) uint_3 ywx; + /// <summary> + /// Property for accessing element 1, 3, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) uint_3 gar; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 3, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_ywx() const __GPU { + return uint_3(_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 3, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_ywx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) uint_3 ywz; + /// <summary> + /// Property for accessing element 1, 3, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) uint_3 gab; + + /// <summary> + /// Returns a uint_3 that is composed of element 1, element 3, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_ywz() const __GPU { + return uint_3(_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 3, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_ywz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) uint_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) uint_3 brg; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 0, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zxy() const __GPU { + return uint_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zxy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) uint_3 zxw; + /// <summary> + /// Property for accessing element 2, 0, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) uint_3 bra; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 0, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zxw() const __GPU { + return uint_3(_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 0, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zxw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) uint_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) uint_3 bgr; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 1, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zyx() const __GPU { + return uint_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zyx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) uint_3 zyw; + /// <summary> + /// Property for accessing element 2, 1, and 3 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) uint_3 bga; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 1, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zyw() const __GPU { + return uint_3(_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 1, and 3 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zyw(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) uint_3 zwx; + /// <summary> + /// Property for accessing element 2, 3, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) uint_3 bar; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 3, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zwx() const __GPU { + return uint_3(_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 3, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zwx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) uint_3 zwy; + /// <summary> + /// Property for accessing element 2, 3, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) uint_3 bag; + + /// <summary> + /// Returns a uint_3 that is composed of element 2, element 3, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_zwy() const __GPU { + return uint_3(_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 3, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_zwy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) uint_3 wxy; + /// <summary> + /// Property for accessing element 3, 0, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) uint_3 arg; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 0, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wxy() const __GPU { + return uint_3(_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 0, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wxy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) uint_3 wxz; + /// <summary> + /// Property for accessing element 3, 0, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) uint_3 arb; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 0, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wxz() const __GPU { + return uint_3(_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 0, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wxz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) uint_3 wyx; + /// <summary> + /// Property for accessing element 3, 1, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) uint_3 agr; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 1, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wyx() const __GPU { + return uint_3(_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 1, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wyx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) uint_3 wyz; + /// <summary> + /// Property for accessing element 3, 1, and 2 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) uint_3 agb; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 1, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wyz() const __GPU { + return uint_3(_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 1, and 2 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wyz(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) uint_3 wzx; + /// <summary> + /// Property for accessing element 3, 2, and 0 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) uint_3 abr; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 2, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wzx() const __GPU { + return uint_3(_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 2, and 0 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wzx(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) uint_3 wzy; + /// <summary> + /// Property for accessing element 3, 2, and 1 of this uint_4 as a uint_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) uint_3 abg; + + /// <summary> + /// Returns a uint_3 that is composed of element 3, element 2, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_3. + /// </returns> + uint_3 get_wzy() const __GPU { + return uint_3(_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 2, and 1 of this uint_4 with a uint_3. + /// </summary> + /// <param name="_Value"> + /// a uint_3 value. + /// </param> + void set_wzy(const uint_3& _Value) __GPU + { + uint_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) uint_4 xyzw; + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) uint_4 rgba; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 1, element 2, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xyzw() const __GPU { + return uint_4(_M_x,_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 1, 2, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xyzw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) uint_4 xywz; + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) uint_4 rgab; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 1, element 3, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xywz() const __GPU { + return uint_4(_M_x,_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 1, 3, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xywz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) uint_4 xzyw; + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) uint_4 rbga; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 2, element 1, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xzyw() const __GPU { + return uint_4(_M_x,_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 2, 1, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xzyw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) uint_4 xzwy; + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) uint_4 rbag; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 2, element 3, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xzwy() const __GPU { + return uint_4(_M_x,_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 2, 3, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xzwy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) uint_4 xwyz; + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) uint_4 ragb; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 3, element 1, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xwyz() const __GPU { + return uint_4(_M_x,_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 3, 1, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xwyz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) uint_4 xwzy; + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) uint_4 rabg; + + /// <summary> + /// Returns a uint_4 that is composed of element 0, element 3, element 2, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_xwzy() const __GPU { + return uint_4(_M_x,_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 3, 2, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_xwzy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) uint_4 yxzw; + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) uint_4 grba; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 0, element 2, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_yxzw() const __GPU { + return uint_4(_M_y,_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 0, 2, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_yxzw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) uint_4 yxwz; + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) uint_4 grab; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 0, element 3, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_yxwz() const __GPU { + return uint_4(_M_y,_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 0, 3, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_yxwz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) uint_4 yzxw; + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) uint_4 gbra; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 2, element 0, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_yzxw() const __GPU { + return uint_4(_M_y,_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 2, 0, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_yzxw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) uint_4 yzwx; + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) uint_4 gbar; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 2, element 3, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_yzwx() const __GPU { + return uint_4(_M_y,_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 2, 3, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_yzwx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) uint_4 ywxz; + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) uint_4 garb; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 3, element 0, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_ywxz() const __GPU { + return uint_4(_M_y,_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 3, 0, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_ywxz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) uint_4 ywzx; + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) uint_4 gabr; + + /// <summary> + /// Returns a uint_4 that is composed of element 1, element 3, element 2, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_ywzx() const __GPU { + return uint_4(_M_y,_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 3, 2, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_ywzx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) uint_4 zxyw; + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) uint_4 brga; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 0, element 1, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zxyw() const __GPU { + return uint_4(_M_z,_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 0, 1, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zxyw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) uint_4 zxwy; + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) uint_4 brag; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 0, element 3, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zxwy() const __GPU { + return uint_4(_M_z,_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 0, 3, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zxwy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) uint_4 zyxw; + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) uint_4 bgra; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 1, element 0, and element 3 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zyxw() const __GPU { + return uint_4(_M_z,_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 1, 0, and 3 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zyxw(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) uint_4 zywx; + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) uint_4 bgar; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 1, element 3, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zywx() const __GPU { + return uint_4(_M_z,_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 1, 3, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zywx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) uint_4 zwxy; + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) uint_4 barg; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 3, element 0, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zwxy() const __GPU { + return uint_4(_M_z,_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 3, 0, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zwxy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) uint_4 zwyx; + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) uint_4 bagr; + + /// <summary> + /// Returns a uint_4 that is composed of element 2, element 3, element 1, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_zwyx() const __GPU { + return uint_4(_M_z,_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 3, 1, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_zwyx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) uint_4 wxyz; + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) uint_4 argb; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 0, element 1, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wxyz() const __GPU { + return uint_4(_M_w,_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 0, 1, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wxyz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) uint_4 wxzy; + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) uint_4 arbg; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 0, element 2, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wxzy() const __GPU { + return uint_4(_M_w,_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 0, 2, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wxzy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) uint_4 wyxz; + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) uint_4 agrb; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 1, element 0, and element 2 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wyxz() const __GPU { + return uint_4(_M_w,_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 1, 0, and 2 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wyxz(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) uint_4 wyzx; + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) uint_4 agbr; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 1, element 2, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wyzx() const __GPU { + return uint_4(_M_w,_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 1, 2, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wyzx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) uint_4 wzxy; + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) uint_4 abrg; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 2, element 0, and element 1 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wzxy() const __GPU { + return uint_4(_M_w,_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 2, 0, and 1 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wzxy(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) uint_4 wzyx; + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this uint_4 as a uint_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) uint_4 abgr; + + /// <summary> + /// Returns a uint_4 that is composed of element 3, element 2, element 1, and element 0 of this uint_4. + /// </summary> + /// <returns> + /// a uint_4. + /// </returns> + uint_4 get_wzyx() const __GPU { + return uint_4(_M_w,_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 2, 1, and 0 of this uint_4 with a uint_4. + /// </summary> + /// <param name="_Value"> + /// a uint_4 value. + /// </param> + void set_wzyx(const uint_4& _Value) __GPU + { + uint_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + }; + + /// <summary> + /// Represent a short vector of 2 int's. + /// </summary> + class int_2 + { + public: + typedef int value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Int_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this int_2 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int x; + /// <summary> + /// Property for accessing element 0 of this int_2 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int r; + + /// <summary> + /// Returns element 0 of this int_2. + /// </summary> + /// <returns> + /// Element 0 of this int_2. + /// </returns> + int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_2. + /// </returns> + int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_2. + /// </returns> + int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this int_2 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_x(int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this int_2 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int y; + /// <summary> + /// Property for accessing element 1 of this int_2 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int g; + + /// <summary> + /// Returns element 1 of this int_2. + /// </summary> + /// <returns> + /// Element 1 of this int_2. + /// </returns> + int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_2. + /// </returns> + int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_2. + /// </returns> + int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this int_2 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_y(int _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + int_2() __GPU + { + _M_x = 0; + _M_y = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + int_2(int _V0, int _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + int_2(int _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_2(const uint_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_2(const float_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_2(const unorm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_2(const norm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_2(const double_2& _Other) __GPU; + + int_2 operator~() const __GPU + { + int_2 _Value = *this; + return int_2(~_Value.x, ~_Value.y); + } + + int_2 operator-() const __GPU + { + int_2 _Value = *this; + return int_2(-_Value.x, -_Value.y); + } + + int_2& operator++() __GPU + { + int_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + int_2 operator++(int) __GPU + { + int_2 _Result = *this; + ++(*this); + return _Result; + } + + int_2& operator--() __GPU + { + int_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + int_2 operator--(int) __GPU + { + int_2 _Result = *this; + --(*this); + return _Result; + } + + int_2& operator+=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator-=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator*=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator/=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator%=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator^=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator|=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator&=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator>>=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + *this = _Value1; + return *this; + } + + int_2& operator<<=(const int_2& _Other) __GPU + { + int_2 _Value1 = *this; + int_2 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this int_2 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this int_2 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 rg; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 1 of this int_2. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xy() const __GPU { + return int_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this int_2 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this int_2 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this int_2 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 gr; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 0 of this int_2. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yx() const __GPU { + return int_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this int_2 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + }; + + /// <summary> + /// Represent a short vector of 3 int's. + /// </summary> + class int_3 + { + public: + typedef int value_type; + static const int size = 3; + private: + static const _Short_vector_base_type_id _Base_type_id = _Int_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + + public: + /// <summary> + /// Property for accessing element 0 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int x; + /// <summary> + /// Property for accessing element 0 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int r; + + /// <summary> + /// Returns element 0 of this int_3. + /// </summary> + /// <returns> + /// Element 0 of this int_3. + /// </returns> + int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_3. + /// </returns> + int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_3. + /// </returns> + int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this int_3 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_x(int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int y; + /// <summary> + /// Property for accessing element 1 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int g; + + /// <summary> + /// Returns element 1 of this int_3. + /// </summary> + /// <returns> + /// Element 1 of this int_3. + /// </returns> + int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_3. + /// </returns> + int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_3. + /// </returns> + int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this int_3 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_y(int _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) int z; + /// <summary> + /// Property for accessing element 2 of this int_3 as an int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) int b; + + /// <summary> + /// Returns element 2 of this int_3. + /// </summary> + /// <returns> + /// Element 2 of this int_3. + /// </returns> + int get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this int_3. + /// </returns> + int& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this int_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this int_3. + /// </returns> + int& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this int_3 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_z(int _Value) __GPU + { + _M_z = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + int_3() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + int_3(int _V0, int _V1, int _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + int_3(int _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_3(const uint_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_3(const float_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_3(const unorm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_3(const norm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_3(const double_3& _Other) __GPU; + + int_3 operator~() const __GPU + { + int_3 _Value = *this; + return int_3(~_Value.x, ~_Value.y, ~_Value.z); + } + + int_3 operator-() const __GPU + { + int_3 _Value = *this; + return int_3(-_Value.x, -_Value.y, -_Value.z); + } + + int_3& operator++() __GPU + { + int_3 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + *this = _Value; + return *this; + } + + int_3 operator++(int) __GPU + { + int_3 _Result = *this; + ++(*this); + return _Result; + } + + int_3& operator--() __GPU + { + int_3 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + *this = _Value; + return *this; + } + + int_3 operator--(int) __GPU + { + int_3 _Result = *this; + --(*this); + return _Result; + } + + int_3& operator+=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator-=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator*=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator/=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator%=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + _Value1.z %= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator^=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + _Value1.z ^= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator|=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + _Value1.z |= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator&=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + _Value1.z &= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator>>=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + _Value1.z >>= _Value2.z; + *this = _Value1; + return *this; + } + + int_3& operator<<=(const int_3& _Other) __GPU + { + int_3 _Value1 = *this; + int_3 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + _Value1.z <<= _Value2.z; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 rg; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 1 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xy() const __GPU { + return int_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) int_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) int_2 rb; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 2 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xz() const __GPU { + return int_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xz(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 gr; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 0 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yx() const __GPU { + return int_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) int_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) int_2 gb; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 2 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yz() const __GPU { + return int_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yz(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) int_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) int_2 br; + + /// <summary> + /// Returns an int_2 that is composed of element 2, and element 0 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_zx() const __GPU { + return int_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_zx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) int_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this int_3 as an int_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) int_2 bg; + + /// <summary> + /// Returns an int_2 that is composed of element 2, and element 1 of this int_3. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_zy() const __GPU { + return int_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this int_3 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_zy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) int_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) int_3 rgb; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 1, and element 2 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xyz() const __GPU { + return int_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xyz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) int_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) int_3 rbg; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 2, and element 1 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xzy() const __GPU { + return int_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xzy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) int_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) int_3 grb; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 0, and element 2 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yxz() const __GPU { + return int_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yxz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) int_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) int_3 gbr; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 2, and element 0 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yzx() const __GPU { + return int_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yzx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) int_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) int_3 brg; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 0, and element 1 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zxy() const __GPU { + return int_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zxy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) int_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this int_3 as an int_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) int_3 bgr; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 1, and element 0 of this int_3. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zyx() const __GPU { + return int_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this int_3 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zyx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + }; + + /// <summary> + /// Represent a short vector of 4 int's. + /// </summary> + class int_4 + { + public: + typedef int value_type; + static const int size = 4; + private: + static const _Short_vector_base_type_id _Base_type_id = _Int_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + value_type _M_w; + + public: + /// <summary> + /// Property for accessing element 0 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int x; + /// <summary> + /// Property for accessing element 0 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) int r; + + /// <summary> + /// Returns element 0 of this int_4. + /// </summary> + /// <returns> + /// Element 0 of this int_4. + /// </returns> + int get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_4. + /// </returns> + int& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this int_4. + /// </returns> + int& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this int_4 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_x(int _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int y; + /// <summary> + /// Property for accessing element 1 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) int g; + + /// <summary> + /// Returns element 1 of this int_4. + /// </summary> + /// <returns> + /// Element 1 of this int_4. + /// </returns> + int get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_4. + /// </returns> + int& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this int_4. + /// </returns> + int& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this int_4 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_y(int _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) int z; + /// <summary> + /// Property for accessing element 2 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) int b; + + /// <summary> + /// Returns element 2 of this int_4. + /// </summary> + /// <returns> + /// Element 2 of this int_4. + /// </returns> + int get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this int_4. + /// </returns> + int& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this int_4. + /// </returns> + int& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this int_4 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_z(int _Value) __GPU + { + _M_z = _Value; + } + + /// <summary> + /// Property for accessing element 3 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) int w; + /// <summary> + /// Property for accessing element 3 of this int_4 as an int. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) int a; + + /// <summary> + /// Returns element 3 of this int_4. + /// </summary> + /// <returns> + /// Element 3 of this int_4. + /// </returns> + int get_w() const __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this int_4. + /// </returns> + int& ref_w() __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this int_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this int_4. + /// </returns> + int& ref_a() __GPU { + return _M_w; + } + + /// <summary> + /// Set element 3 of this int_4 with an int. + /// </summary> + /// <param name="_Value"> + /// an int value. + /// </param> + void set_w(int _Value) __GPU + { + _M_w = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + int_4() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + _M_w = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + int_4(int _V0, int _V1, int _V2, int _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + int_4(int _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + _M_w = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_4(const uint_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_4(const float_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_4(const unorm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_4(const norm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline int_4(const double_4& _Other) __GPU; + + int_4 operator~() const __GPU + { + int_4 _Value = *this; + return int_4(~_Value.x, ~_Value.y, ~_Value.z, ~_Value.w); + } + + int_4 operator-() const __GPU + { + int_4 _Value = *this; + return int_4(-_Value.x, -_Value.y, -_Value.z, -_Value.w); + } + + int_4& operator++() __GPU + { + int_4 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + ++_Value._M_w; + *this = _Value; + return *this; + } + + int_4 operator++(int) __GPU + { + int_4 _Result = *this; + ++(*this); + return _Result; + } + + int_4& operator--() __GPU + { + int_4 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + --_Value._M_w; + *this = _Value; + return *this; + } + + int_4 operator--(int) __GPU + { + int_4 _Result = *this; + --(*this); + return _Result; + } + + int_4& operator+=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + _Value1.w += _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator-=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + _Value1.w -= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator*=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + _Value1.w *= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator/=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + _Value1.w /= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator%=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x %= _Value2.x; + _Value1.y %= _Value2.y; + _Value1.z %= _Value2.z; + _Value1.w %= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator^=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x ^= _Value2.x; + _Value1.y ^= _Value2.y; + _Value1.z ^= _Value2.z; + _Value1.w ^= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator|=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x |= _Value2.x; + _Value1.y |= _Value2.y; + _Value1.z |= _Value2.z; + _Value1.w |= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator&=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x &= _Value2.x; + _Value1.y &= _Value2.y; + _Value1.z &= _Value2.z; + _Value1.w &= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator>>=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x >>= _Value2.x; + _Value1.y >>= _Value2.y; + _Value1.z >>= _Value2.z; + _Value1.w >>= _Value2.w; + *this = _Value1; + return *this; + } + + int_4& operator<<=(const int_4& _Other) __GPU + { + int_4 _Value1 = *this; + int_4 _Value2 = _Other; + _Value1.x <<= _Value2.x; + _Value1.y <<= _Value2.y; + _Value1.z <<= _Value2.z; + _Value1.w <<= _Value2.w; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) int_2 rg; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xy() const __GPU { + return int_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) int_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) int_2 rb; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xz() const __GPU { + return int_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xz(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) int_2 xw; + /// <summary> + /// Property for accessing element 0, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) int_2 ra; + + /// <summary> + /// Returns an int_2 that is composed of element 0, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_xw() const __GPU { + return int_2(_M_x,_M_w); + } + + /// <summary> + /// Set element 0, and 3 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_xw(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) int_2 gr; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yx() const __GPU { + return int_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) int_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) int_2 gb; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yz() const __GPU { + return int_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yz(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) int_2 yw; + /// <summary> + /// Property for accessing element 1, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) int_2 ga; + + /// <summary> + /// Returns an int_2 that is composed of element 1, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_yw() const __GPU { + return int_2(_M_y,_M_w); + } + + /// <summary> + /// Set element 1, and 3 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_yw(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) int_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) int_2 br; + + /// <summary> + /// Returns an int_2 that is composed of element 2, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_zx() const __GPU { + return int_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_zx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) int_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) int_2 bg; + + /// <summary> + /// Returns an int_2 that is composed of element 2, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_zy() const __GPU { + return int_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_zy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) int_2 zw; + /// <summary> + /// Property for accessing element 2, and 3 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) int_2 ba; + + /// <summary> + /// Returns an int_2 that is composed of element 2, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_zw() const __GPU { + return int_2(_M_z,_M_w); + } + + /// <summary> + /// Set element 2, and 3 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_zw(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) int_2 wx; + /// <summary> + /// Property for accessing element 3, and 0 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) int_2 ar; + + /// <summary> + /// Returns an int_2 that is composed of element 3, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_wx() const __GPU { + return int_2(_M_w,_M_x); + } + + /// <summary> + /// Set element 3, and 0 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_wx(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) int_2 wy; + /// <summary> + /// Property for accessing element 3, and 1 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) int_2 ag; + + /// <summary> + /// Returns an int_2 that is composed of element 3, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_wy() const __GPU { + return int_2(_M_w,_M_y); + } + + /// <summary> + /// Set element 3, and 1 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_wy(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) int_2 wz; + /// <summary> + /// Property for accessing element 3, and 2 of this int_4 as an int_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) int_2 ab; + + /// <summary> + /// Returns an int_2 that is composed of element 3, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_2. + /// </returns> + int_2 get_wz() const __GPU { + return int_2(_M_w,_M_z); + } + + /// <summary> + /// Set element 3, and 2 of this int_4 with an int_2. + /// </summary> + /// <param name="_Value"> + /// an int_2 value. + /// </param> + void set_wz(const int_2& _Value) __GPU + { + int_2 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) int_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) int_3 rgb; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 1, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xyz() const __GPU { + return int_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xyz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) int_3 xyw; + /// <summary> + /// Property for accessing element 0, 1, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) int_3 rga; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 1, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xyw() const __GPU { + return int_3(_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 1, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xyw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) int_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) int_3 rbg; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 2, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xzy() const __GPU { + return int_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xzy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) int_3 xzw; + /// <summary> + /// Property for accessing element 0, 2, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) int_3 rba; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 2, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xzw() const __GPU { + return int_3(_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 2, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xzw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) int_3 xwy; + /// <summary> + /// Property for accessing element 0, 3, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) int_3 rag; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 3, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xwy() const __GPU { + return int_3(_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 3, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xwy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) int_3 xwz; + /// <summary> + /// Property for accessing element 0, 3, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) int_3 rab; + + /// <summary> + /// Returns an int_3 that is composed of element 0, element 3, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_xwz() const __GPU { + return int_3(_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 3, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_xwz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) int_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) int_3 grb; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 0, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yxz() const __GPU { + return int_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yxz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) int_3 yxw; + /// <summary> + /// Property for accessing element 1, 0, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) int_3 gra; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 0, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yxw() const __GPU { + return int_3(_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 0, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yxw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) int_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) int_3 gbr; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 2, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yzx() const __GPU { + return int_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yzx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) int_3 yzw; + /// <summary> + /// Property for accessing element 1, 2, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) int_3 gba; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 2, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_yzw() const __GPU { + return int_3(_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 2, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_yzw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) int_3 ywx; + /// <summary> + /// Property for accessing element 1, 3, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) int_3 gar; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 3, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_ywx() const __GPU { + return int_3(_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 3, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_ywx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) int_3 ywz; + /// <summary> + /// Property for accessing element 1, 3, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) int_3 gab; + + /// <summary> + /// Returns an int_3 that is composed of element 1, element 3, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_ywz() const __GPU { + return int_3(_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 3, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_ywz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) int_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) int_3 brg; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 0, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zxy() const __GPU { + return int_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zxy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) int_3 zxw; + /// <summary> + /// Property for accessing element 2, 0, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) int_3 bra; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 0, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zxw() const __GPU { + return int_3(_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 0, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zxw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) int_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) int_3 bgr; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 1, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zyx() const __GPU { + return int_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zyx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) int_3 zyw; + /// <summary> + /// Property for accessing element 2, 1, and 3 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) int_3 bga; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 1, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zyw() const __GPU { + return int_3(_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 1, and 3 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zyw(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) int_3 zwx; + /// <summary> + /// Property for accessing element 2, 3, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) int_3 bar; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 3, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zwx() const __GPU { + return int_3(_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 3, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zwx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) int_3 zwy; + /// <summary> + /// Property for accessing element 2, 3, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) int_3 bag; + + /// <summary> + /// Returns an int_3 that is composed of element 2, element 3, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_zwy() const __GPU { + return int_3(_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 3, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_zwy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) int_3 wxy; + /// <summary> + /// Property for accessing element 3, 0, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) int_3 arg; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 0, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wxy() const __GPU { + return int_3(_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 0, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wxy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) int_3 wxz; + /// <summary> + /// Property for accessing element 3, 0, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) int_3 arb; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 0, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wxz() const __GPU { + return int_3(_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 0, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wxz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) int_3 wyx; + /// <summary> + /// Property for accessing element 3, 1, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) int_3 agr; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 1, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wyx() const __GPU { + return int_3(_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 1, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wyx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) int_3 wyz; + /// <summary> + /// Property for accessing element 3, 1, and 2 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) int_3 agb; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 1, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wyz() const __GPU { + return int_3(_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 1, and 2 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wyz(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) int_3 wzx; + /// <summary> + /// Property for accessing element 3, 2, and 0 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) int_3 abr; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 2, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wzx() const __GPU { + return int_3(_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 2, and 0 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wzx(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) int_3 wzy; + /// <summary> + /// Property for accessing element 3, 2, and 1 of this int_4 as an int_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) int_3 abg; + + /// <summary> + /// Returns an int_3 that is composed of element 3, element 2, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_3. + /// </returns> + int_3 get_wzy() const __GPU { + return int_3(_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 2, and 1 of this int_4 with an int_3. + /// </summary> + /// <param name="_Value"> + /// an int_3 value. + /// </param> + void set_wzy(const int_3& _Value) __GPU + { + int_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) int_4 xyzw; + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) int_4 rgba; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 1, element 2, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xyzw() const __GPU { + return int_4(_M_x,_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 1, 2, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xyzw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) int_4 xywz; + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) int_4 rgab; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 1, element 3, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xywz() const __GPU { + return int_4(_M_x,_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 1, 3, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xywz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) int_4 xzyw; + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) int_4 rbga; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 2, element 1, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xzyw() const __GPU { + return int_4(_M_x,_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 2, 1, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xzyw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) int_4 xzwy; + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) int_4 rbag; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 2, element 3, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xzwy() const __GPU { + return int_4(_M_x,_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 2, 3, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xzwy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) int_4 xwyz; + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) int_4 ragb; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 3, element 1, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xwyz() const __GPU { + return int_4(_M_x,_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 3, 1, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xwyz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) int_4 xwzy; + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) int_4 rabg; + + /// <summary> + /// Returns an int_4 that is composed of element 0, element 3, element 2, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_xwzy() const __GPU { + return int_4(_M_x,_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 3, 2, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_xwzy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) int_4 yxzw; + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) int_4 grba; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 0, element 2, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_yxzw() const __GPU { + return int_4(_M_y,_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 0, 2, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_yxzw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) int_4 yxwz; + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) int_4 grab; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 0, element 3, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_yxwz() const __GPU { + return int_4(_M_y,_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 0, 3, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_yxwz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) int_4 yzxw; + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) int_4 gbra; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 2, element 0, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_yzxw() const __GPU { + return int_4(_M_y,_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 2, 0, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_yzxw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) int_4 yzwx; + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) int_4 gbar; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 2, element 3, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_yzwx() const __GPU { + return int_4(_M_y,_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 2, 3, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_yzwx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) int_4 ywxz; + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) int_4 garb; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 3, element 0, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_ywxz() const __GPU { + return int_4(_M_y,_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 3, 0, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_ywxz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) int_4 ywzx; + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) int_4 gabr; + + /// <summary> + /// Returns an int_4 that is composed of element 1, element 3, element 2, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_ywzx() const __GPU { + return int_4(_M_y,_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 3, 2, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_ywzx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) int_4 zxyw; + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) int_4 brga; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 0, element 1, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zxyw() const __GPU { + return int_4(_M_z,_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 0, 1, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zxyw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) int_4 zxwy; + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) int_4 brag; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 0, element 3, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zxwy() const __GPU { + return int_4(_M_z,_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 0, 3, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zxwy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) int_4 zyxw; + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) int_4 bgra; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 1, element 0, and element 3 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zyxw() const __GPU { + return int_4(_M_z,_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 1, 0, and 3 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zyxw(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) int_4 zywx; + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) int_4 bgar; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 1, element 3, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zywx() const __GPU { + return int_4(_M_z,_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 1, 3, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zywx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) int_4 zwxy; + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) int_4 barg; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 3, element 0, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zwxy() const __GPU { + return int_4(_M_z,_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 3, 0, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zwxy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) int_4 zwyx; + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) int_4 bagr; + + /// <summary> + /// Returns an int_4 that is composed of element 2, element 3, element 1, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_zwyx() const __GPU { + return int_4(_M_z,_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 3, 1, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_zwyx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) int_4 wxyz; + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) int_4 argb; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 0, element 1, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wxyz() const __GPU { + return int_4(_M_w,_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 0, 1, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wxyz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) int_4 wxzy; + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) int_4 arbg; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 0, element 2, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wxzy() const __GPU { + return int_4(_M_w,_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 0, 2, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wxzy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) int_4 wyxz; + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) int_4 agrb; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 1, element 0, and element 2 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wyxz() const __GPU { + return int_4(_M_w,_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 1, 0, and 2 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wyxz(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) int_4 wyzx; + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) int_4 agbr; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 1, element 2, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wyzx() const __GPU { + return int_4(_M_w,_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 1, 2, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wyzx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) int_4 wzxy; + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) int_4 abrg; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 2, element 0, and element 1 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wzxy() const __GPU { + return int_4(_M_w,_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 2, 0, and 1 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wzxy(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) int_4 wzyx; + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this int_4 as an int_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) int_4 abgr; + + /// <summary> + /// Returns an int_4 that is composed of element 3, element 2, element 1, and element 0 of this int_4. + /// </summary> + /// <returns> + /// an int_4. + /// </returns> + int_4 get_wzyx() const __GPU { + return int_4(_M_w,_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 2, 1, and 0 of this int_4 with an int_4. + /// </summary> + /// <param name="_Value"> + /// an int_4 value. + /// </param> + void set_wzyx(const int_4& _Value) __GPU + { + int_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + }; + + /// <summary> + /// Represent a short vector of 2 float's. + /// </summary> + class float_2 + { + public: + typedef float value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Float_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this float_2 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float x; + /// <summary> + /// Property for accessing element 0 of this float_2 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float r; + + /// <summary> + /// Returns element 0 of this float_2. + /// </summary> + /// <returns> + /// Element 0 of this float_2. + /// </returns> + float get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_2. + /// </returns> + float& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_2. + /// </returns> + float& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this float_2 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_x(float _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this float_2 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float y; + /// <summary> + /// Property for accessing element 1 of this float_2 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float g; + + /// <summary> + /// Returns element 1 of this float_2. + /// </summary> + /// <returns> + /// Element 1 of this float_2. + /// </returns> + float get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_2. + /// </returns> + float& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_2. + /// </returns> + float& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this float_2 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_y(float _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + float_2() __GPU + { + _M_x = 0; + _M_y = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + float_2(float _V0, float _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + float_2(float _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_2(const uint_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_2(const int_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_2(const unorm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_2(const norm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_2(const double_2& _Other) __GPU; + + float_2 operator-() const __GPU + { + float_2 _Value = *this; + return float_2(-_Value.x, -_Value.y); + } + + float_2& operator++() __GPU + { + float_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + float_2 operator++(int) __GPU + { + float_2 _Result = *this; + ++(*this); + return _Result; + } + + float_2& operator--() __GPU + { + float_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + float_2 operator--(int) __GPU + { + float_2 _Result = *this; + --(*this); + return _Result; + } + + float_2& operator+=(const float_2& _Other) __GPU + { + float_2 _Value1 = *this; + float_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + float_2& operator-=(const float_2& _Other) __GPU + { + float_2 _Value1 = *this; + float_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + float_2& operator*=(const float_2& _Other) __GPU + { + float_2 _Value1 = *this; + float_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + float_2& operator/=(const float_2& _Other) __GPU + { + float_2 _Value1 = *this; + float_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this float_2 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this float_2 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 rg; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 1 of this float_2. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xy() const __GPU { + return float_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this float_2 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this float_2 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this float_2 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 gr; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 0 of this float_2. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yx() const __GPU { + return float_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this float_2 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + }; + + /// <summary> + /// Represent a short vector of 3 float's. + /// </summary> + class float_3 + { + public: + typedef float value_type; + static const int size = 3; + private: + static const _Short_vector_base_type_id _Base_type_id = _Float_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + + public: + /// <summary> + /// Property for accessing element 0 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float x; + /// <summary> + /// Property for accessing element 0 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float r; + + /// <summary> + /// Returns element 0 of this float_3. + /// </summary> + /// <returns> + /// Element 0 of this float_3. + /// </returns> + float get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_3. + /// </returns> + float& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_3. + /// </returns> + float& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this float_3 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_x(float _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float y; + /// <summary> + /// Property for accessing element 1 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float g; + + /// <summary> + /// Returns element 1 of this float_3. + /// </summary> + /// <returns> + /// Element 1 of this float_3. + /// </returns> + float get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_3. + /// </returns> + float& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_3. + /// </returns> + float& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this float_3 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_y(float _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) float z; + /// <summary> + /// Property for accessing element 2 of this float_3 as a float. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) float b; + + /// <summary> + /// Returns element 2 of this float_3. + /// </summary> + /// <returns> + /// Element 2 of this float_3. + /// </returns> + float get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this float_3. + /// </returns> + float& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this float_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this float_3. + /// </returns> + float& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this float_3 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_z(float _Value) __GPU + { + _M_z = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + float_3() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + float_3(float _V0, float _V1, float _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + float_3(float _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_3(const uint_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_3(const int_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_3(const unorm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_3(const norm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_3(const double_3& _Other) __GPU; + + float_3 operator-() const __GPU + { + float_3 _Value = *this; + return float_3(-_Value.x, -_Value.y, -_Value.z); + } + + float_3& operator++() __GPU + { + float_3 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + *this = _Value; + return *this; + } + + float_3 operator++(int) __GPU + { + float_3 _Result = *this; + ++(*this); + return _Result; + } + + float_3& operator--() __GPU + { + float_3 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + *this = _Value; + return *this; + } + + float_3 operator--(int) __GPU + { + float_3 _Result = *this; + --(*this); + return _Result; + } + + float_3& operator+=(const float_3& _Other) __GPU + { + float_3 _Value1 = *this; + float_3 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + *this = _Value1; + return *this; + } + + float_3& operator-=(const float_3& _Other) __GPU + { + float_3 _Value1 = *this; + float_3 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + *this = _Value1; + return *this; + } + + float_3& operator*=(const float_3& _Other) __GPU + { + float_3 _Value1 = *this; + float_3 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + *this = _Value1; + return *this; + } + + float_3& operator/=(const float_3& _Other) __GPU + { + float_3 _Value1 = *this; + float_3 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 rg; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 1 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xy() const __GPU { + return float_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) float_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) float_2 rb; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 2 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xz() const __GPU { + return float_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xz(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 gr; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 0 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yx() const __GPU { + return float_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) float_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) float_2 gb; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 2 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yz() const __GPU { + return float_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yz(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) float_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) float_2 br; + + /// <summary> + /// Returns a float_2 that is composed of element 2, and element 0 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_zx() const __GPU { + return float_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_zx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) float_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this float_3 as a float_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) float_2 bg; + + /// <summary> + /// Returns a float_2 that is composed of element 2, and element 1 of this float_3. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_zy() const __GPU { + return float_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this float_3 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_zy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) float_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) float_3 rgb; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 1, and element 2 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xyz() const __GPU { + return float_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xyz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) float_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) float_3 rbg; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 2, and element 1 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xzy() const __GPU { + return float_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xzy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) float_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) float_3 grb; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 0, and element 2 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yxz() const __GPU { + return float_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yxz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) float_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) float_3 gbr; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 2, and element 0 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yzx() const __GPU { + return float_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yzx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) float_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) float_3 brg; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 0, and element 1 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zxy() const __GPU { + return float_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zxy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) float_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this float_3 as a float_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) float_3 bgr; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 1, and element 0 of this float_3. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zyx() const __GPU { + return float_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this float_3 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zyx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + }; + + /// <summary> + /// Represent a short vector of 4 float's. + /// </summary> + class float_4 + { + public: + typedef float value_type; + static const int size = 4; + private: + static const _Short_vector_base_type_id _Base_type_id = _Float_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + value_type _M_w; + + public: + /// <summary> + /// Property for accessing element 0 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float x; + /// <summary> + /// Property for accessing element 0 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) float r; + + /// <summary> + /// Returns element 0 of this float_4. + /// </summary> + /// <returns> + /// Element 0 of this float_4. + /// </returns> + float get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_4. + /// </returns> + float& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this float_4. + /// </returns> + float& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this float_4 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_x(float _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float y; + /// <summary> + /// Property for accessing element 1 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) float g; + + /// <summary> + /// Returns element 1 of this float_4. + /// </summary> + /// <returns> + /// Element 1 of this float_4. + /// </returns> + float get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_4. + /// </returns> + float& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this float_4. + /// </returns> + float& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this float_4 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_y(float _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) float z; + /// <summary> + /// Property for accessing element 2 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) float b; + + /// <summary> + /// Returns element 2 of this float_4. + /// </summary> + /// <returns> + /// Element 2 of this float_4. + /// </returns> + float get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this float_4. + /// </returns> + float& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this float_4. + /// </returns> + float& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this float_4 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_z(float _Value) __GPU + { + _M_z = _Value; + } + + /// <summary> + /// Property for accessing element 3 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) float w; + /// <summary> + /// Property for accessing element 3 of this float_4 as a float. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) float a; + + /// <summary> + /// Returns element 3 of this float_4. + /// </summary> + /// <returns> + /// Element 3 of this float_4. + /// </returns> + float get_w() const __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this float_4. + /// </returns> + float& ref_w() __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this float_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this float_4. + /// </returns> + float& ref_a() __GPU { + return _M_w; + } + + /// <summary> + /// Set element 3 of this float_4 with a float. + /// </summary> + /// <param name="_Value"> + /// a float value. + /// </param> + void set_w(float _Value) __GPU + { + _M_w = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + float_4() __GPU + { + _M_x = 0; + _M_y = 0; + _M_z = 0; + _M_w = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + float_4(float _V0, float _V1, float _V2, float _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + float_4(float _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + _M_w = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_4(const uint_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_4(const int_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_4(const unorm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_4(const norm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline float_4(const double_4& _Other) __GPU; + + float_4 operator-() const __GPU + { + float_4 _Value = *this; + return float_4(-_Value.x, -_Value.y, -_Value.z, -_Value.w); + } + + float_4& operator++() __GPU + { + float_4 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + ++_Value._M_w; + *this = _Value; + return *this; + } + + float_4 operator++(int) __GPU + { + float_4 _Result = *this; + ++(*this); + return _Result; + } + + float_4& operator--() __GPU + { + float_4 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + --_Value._M_w; + *this = _Value; + return *this; + } + + float_4 operator--(int) __GPU + { + float_4 _Result = *this; + --(*this); + return _Result; + } + + float_4& operator+=(const float_4& _Other) __GPU + { + float_4 _Value1 = *this; + float_4 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + _Value1.w += _Value2.w; + *this = _Value1; + return *this; + } + + float_4& operator-=(const float_4& _Other) __GPU + { + float_4 _Value1 = *this; + float_4 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + _Value1.w -= _Value2.w; + *this = _Value1; + return *this; + } + + float_4& operator*=(const float_4& _Other) __GPU + { + float_4 _Value1 = *this; + float_4 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + _Value1.w *= _Value2.w; + *this = _Value1; + return *this; + } + + float_4& operator/=(const float_4& _Other) __GPU + { + float_4 _Value1 = *this; + float_4 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + _Value1.w /= _Value2.w; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) float_2 rg; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xy() const __GPU { + return float_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) float_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) float_2 rb; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xz() const __GPU { + return float_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xz(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) float_2 xw; + /// <summary> + /// Property for accessing element 0, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) float_2 ra; + + /// <summary> + /// Returns a float_2 that is composed of element 0, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_xw() const __GPU { + return float_2(_M_x,_M_w); + } + + /// <summary> + /// Set element 0, and 3 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_xw(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) float_2 gr; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yx() const __GPU { + return float_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) float_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) float_2 gb; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yz() const __GPU { + return float_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yz(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) float_2 yw; + /// <summary> + /// Property for accessing element 1, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) float_2 ga; + + /// <summary> + /// Returns a float_2 that is composed of element 1, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_yw() const __GPU { + return float_2(_M_y,_M_w); + } + + /// <summary> + /// Set element 1, and 3 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_yw(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) float_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) float_2 br; + + /// <summary> + /// Returns a float_2 that is composed of element 2, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_zx() const __GPU { + return float_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_zx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) float_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) float_2 bg; + + /// <summary> + /// Returns a float_2 that is composed of element 2, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_zy() const __GPU { + return float_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_zy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) float_2 zw; + /// <summary> + /// Property for accessing element 2, and 3 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) float_2 ba; + + /// <summary> + /// Returns a float_2 that is composed of element 2, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_zw() const __GPU { + return float_2(_M_z,_M_w); + } + + /// <summary> + /// Set element 2, and 3 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_zw(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) float_2 wx; + /// <summary> + /// Property for accessing element 3, and 0 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) float_2 ar; + + /// <summary> + /// Returns a float_2 that is composed of element 3, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_wx() const __GPU { + return float_2(_M_w,_M_x); + } + + /// <summary> + /// Set element 3, and 0 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_wx(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) float_2 wy; + /// <summary> + /// Property for accessing element 3, and 1 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) float_2 ag; + + /// <summary> + /// Returns a float_2 that is composed of element 3, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_wy() const __GPU { + return float_2(_M_w,_M_y); + } + + /// <summary> + /// Set element 3, and 1 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_wy(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) float_2 wz; + /// <summary> + /// Property for accessing element 3, and 2 of this float_4 as a float_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) float_2 ab; + + /// <summary> + /// Returns a float_2 that is composed of element 3, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_2. + /// </returns> + float_2 get_wz() const __GPU { + return float_2(_M_w,_M_z); + } + + /// <summary> + /// Set element 3, and 2 of this float_4 with a float_2. + /// </summary> + /// <param name="_Value"> + /// a float_2 value. + /// </param> + void set_wz(const float_2& _Value) __GPU + { + float_2 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) float_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) float_3 rgb; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 1, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xyz() const __GPU { + return float_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xyz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) float_3 xyw; + /// <summary> + /// Property for accessing element 0, 1, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) float_3 rga; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 1, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xyw() const __GPU { + return float_3(_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 1, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xyw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) float_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) float_3 rbg; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 2, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xzy() const __GPU { + return float_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xzy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) float_3 xzw; + /// <summary> + /// Property for accessing element 0, 2, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) float_3 rba; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 2, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xzw() const __GPU { + return float_3(_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 2, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xzw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) float_3 xwy; + /// <summary> + /// Property for accessing element 0, 3, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) float_3 rag; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 3, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xwy() const __GPU { + return float_3(_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 3, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xwy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) float_3 xwz; + /// <summary> + /// Property for accessing element 0, 3, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) float_3 rab; + + /// <summary> + /// Returns a float_3 that is composed of element 0, element 3, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_xwz() const __GPU { + return float_3(_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 3, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_xwz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) float_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) float_3 grb; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 0, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yxz() const __GPU { + return float_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yxz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) float_3 yxw; + /// <summary> + /// Property for accessing element 1, 0, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) float_3 gra; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 0, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yxw() const __GPU { + return float_3(_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 0, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yxw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) float_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) float_3 gbr; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 2, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yzx() const __GPU { + return float_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yzx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) float_3 yzw; + /// <summary> + /// Property for accessing element 1, 2, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) float_3 gba; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 2, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_yzw() const __GPU { + return float_3(_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 2, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_yzw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) float_3 ywx; + /// <summary> + /// Property for accessing element 1, 3, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) float_3 gar; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 3, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_ywx() const __GPU { + return float_3(_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 3, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_ywx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) float_3 ywz; + /// <summary> + /// Property for accessing element 1, 3, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) float_3 gab; + + /// <summary> + /// Returns a float_3 that is composed of element 1, element 3, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_ywz() const __GPU { + return float_3(_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 3, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_ywz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) float_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) float_3 brg; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 0, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zxy() const __GPU { + return float_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zxy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) float_3 zxw; + /// <summary> + /// Property for accessing element 2, 0, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) float_3 bra; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 0, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zxw() const __GPU { + return float_3(_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 0, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zxw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) float_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) float_3 bgr; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 1, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zyx() const __GPU { + return float_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zyx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) float_3 zyw; + /// <summary> + /// Property for accessing element 2, 1, and 3 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) float_3 bga; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 1, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zyw() const __GPU { + return float_3(_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 1, and 3 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zyw(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) float_3 zwx; + /// <summary> + /// Property for accessing element 2, 3, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) float_3 bar; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 3, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zwx() const __GPU { + return float_3(_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 3, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zwx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) float_3 zwy; + /// <summary> + /// Property for accessing element 2, 3, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) float_3 bag; + + /// <summary> + /// Returns a float_3 that is composed of element 2, element 3, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_zwy() const __GPU { + return float_3(_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 3, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_zwy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) float_3 wxy; + /// <summary> + /// Property for accessing element 3, 0, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) float_3 arg; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 0, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wxy() const __GPU { + return float_3(_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 0, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wxy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) float_3 wxz; + /// <summary> + /// Property for accessing element 3, 0, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) float_3 arb; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 0, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wxz() const __GPU { + return float_3(_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 0, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wxz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) float_3 wyx; + /// <summary> + /// Property for accessing element 3, 1, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) float_3 agr; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 1, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wyx() const __GPU { + return float_3(_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 1, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wyx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) float_3 wyz; + /// <summary> + /// Property for accessing element 3, 1, and 2 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) float_3 agb; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 1, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wyz() const __GPU { + return float_3(_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 1, and 2 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wyz(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) float_3 wzx; + /// <summary> + /// Property for accessing element 3, 2, and 0 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) float_3 abr; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 2, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wzx() const __GPU { + return float_3(_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 2, and 0 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wzx(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) float_3 wzy; + /// <summary> + /// Property for accessing element 3, 2, and 1 of this float_4 as a float_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) float_3 abg; + + /// <summary> + /// Returns a float_3 that is composed of element 3, element 2, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_3. + /// </returns> + float_3 get_wzy() const __GPU { + return float_3(_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 2, and 1 of this float_4 with a float_3. + /// </summary> + /// <param name="_Value"> + /// a float_3 value. + /// </param> + void set_wzy(const float_3& _Value) __GPU + { + float_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) float_4 xyzw; + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) float_4 rgba; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 1, element 2, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xyzw() const __GPU { + return float_4(_M_x,_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 1, 2, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xyzw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) float_4 xywz; + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) float_4 rgab; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 1, element 3, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xywz() const __GPU { + return float_4(_M_x,_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 1, 3, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xywz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) float_4 xzyw; + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) float_4 rbga; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 2, element 1, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xzyw() const __GPU { + return float_4(_M_x,_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 2, 1, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xzyw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) float_4 xzwy; + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) float_4 rbag; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 2, element 3, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xzwy() const __GPU { + return float_4(_M_x,_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 2, 3, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xzwy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) float_4 xwyz; + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) float_4 ragb; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 3, element 1, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xwyz() const __GPU { + return float_4(_M_x,_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 3, 1, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xwyz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) float_4 xwzy; + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) float_4 rabg; + + /// <summary> + /// Returns a float_4 that is composed of element 0, element 3, element 2, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_xwzy() const __GPU { + return float_4(_M_x,_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 3, 2, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_xwzy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) float_4 yxzw; + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) float_4 grba; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 0, element 2, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_yxzw() const __GPU { + return float_4(_M_y,_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 0, 2, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_yxzw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) float_4 yxwz; + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) float_4 grab; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 0, element 3, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_yxwz() const __GPU { + return float_4(_M_y,_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 0, 3, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_yxwz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) float_4 yzxw; + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) float_4 gbra; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 2, element 0, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_yzxw() const __GPU { + return float_4(_M_y,_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 2, 0, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_yzxw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) float_4 yzwx; + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) float_4 gbar; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 2, element 3, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_yzwx() const __GPU { + return float_4(_M_y,_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 2, 3, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_yzwx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) float_4 ywxz; + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) float_4 garb; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 3, element 0, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_ywxz() const __GPU { + return float_4(_M_y,_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 3, 0, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_ywxz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) float_4 ywzx; + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) float_4 gabr; + + /// <summary> + /// Returns a float_4 that is composed of element 1, element 3, element 2, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_ywzx() const __GPU { + return float_4(_M_y,_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 3, 2, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_ywzx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) float_4 zxyw; + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) float_4 brga; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 0, element 1, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zxyw() const __GPU { + return float_4(_M_z,_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 0, 1, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zxyw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) float_4 zxwy; + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) float_4 brag; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 0, element 3, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zxwy() const __GPU { + return float_4(_M_z,_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 0, 3, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zxwy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) float_4 zyxw; + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) float_4 bgra; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 1, element 0, and element 3 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zyxw() const __GPU { + return float_4(_M_z,_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 1, 0, and 3 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zyxw(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) float_4 zywx; + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) float_4 bgar; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 1, element 3, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zywx() const __GPU { + return float_4(_M_z,_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 1, 3, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zywx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) float_4 zwxy; + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) float_4 barg; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 3, element 0, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zwxy() const __GPU { + return float_4(_M_z,_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 3, 0, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zwxy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) float_4 zwyx; + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) float_4 bagr; + + /// <summary> + /// Returns a float_4 that is composed of element 2, element 3, element 1, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_zwyx() const __GPU { + return float_4(_M_z,_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 3, 1, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_zwyx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) float_4 wxyz; + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) float_4 argb; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 0, element 1, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wxyz() const __GPU { + return float_4(_M_w,_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 0, 1, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wxyz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) float_4 wxzy; + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) float_4 arbg; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 0, element 2, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wxzy() const __GPU { + return float_4(_M_w,_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 0, 2, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wxzy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) float_4 wyxz; + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) float_4 agrb; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 1, element 0, and element 2 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wyxz() const __GPU { + return float_4(_M_w,_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 1, 0, and 2 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wyxz(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) float_4 wyzx; + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) float_4 agbr; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 1, element 2, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wyzx() const __GPU { + return float_4(_M_w,_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 1, 2, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wyzx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) float_4 wzxy; + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) float_4 abrg; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 2, element 0, and element 1 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wzxy() const __GPU { + return float_4(_M_w,_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 2, 0, and 1 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wzxy(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) float_4 wzyx; + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this float_4 as a float_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) float_4 abgr; + + /// <summary> + /// Returns a float_4 that is composed of element 3, element 2, element 1, and element 0 of this float_4. + /// </summary> + /// <returns> + /// a float_4. + /// </returns> + float_4 get_wzyx() const __GPU { + return float_4(_M_w,_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 2, 1, and 0 of this float_4 with a float_4. + /// </summary> + /// <param name="_Value"> + /// a float_4 value. + /// </param> + void set_wzyx(const float_4& _Value) __GPU + { + float_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + }; + + /// <summary> + /// Represent a short vector of 2 unorm's. + /// </summary> + class unorm_2 + { + public: + typedef unorm value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Unorm_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this unorm_2 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm x; + /// <summary> + /// Property for accessing element 0 of this unorm_2 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm r; + + /// <summary> + /// Returns element 0 of this unorm_2. + /// </summary> + /// <returns> + /// Element 0 of this unorm_2. + /// </returns> + unorm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_2. + /// </returns> + unorm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_2. + /// </returns> + unorm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this unorm_2 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_x(unorm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this unorm_2 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm y; + /// <summary> + /// Property for accessing element 1 of this unorm_2 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm g; + + /// <summary> + /// Returns element 1 of this unorm_2. + /// </summary> + /// <returns> + /// Element 1 of this unorm_2. + /// </returns> + unorm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_2. + /// </returns> + unorm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_2. + /// </returns> + unorm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this unorm_2 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_y(unorm _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + unorm_2() __GPU + { + _M_x = unorm(0.0f); + _M_y = unorm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + unorm_2(unorm _V0, unorm _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + unorm_2(float _V0, float _V1) __GPU + { + _M_x = unorm(_V0); + _M_y = unorm(_V1); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + unorm_2(unorm _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + explicit unorm_2(float _V) __GPU + { + _M_x = unorm(_V); + _M_y = unorm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + unorm_2(const unorm_2& _Other) __GPU + { + *this = _Other; + } + + unorm_2& operator=(const unorm_2& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_2(const uint_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_2(const int_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_2(const float_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_2(const norm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_2(const double_2& _Other) __GPU; + + unorm_2& operator++() __GPU + { + unorm_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + unorm_2 operator++(int) __GPU + { + unorm_2 _Result = *this; + ++(*this); + return _Result; + } + + unorm_2& operator--() __GPU + { + unorm_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + unorm_2 operator--(int) __GPU + { + unorm_2 _Result = *this; + --(*this); + return _Result; + } + + unorm_2& operator+=(const unorm_2& _Other) __GPU + { + unorm_2 _Value1 = *this; + unorm_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + unorm_2& operator-=(const unorm_2& _Other) __GPU + { + unorm_2 _Value1 = *this; + unorm_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + unorm_2& operator*=(const unorm_2& _Other) __GPU + { + unorm_2 _Value1 = *this; + unorm_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + unorm_2& operator/=(const unorm_2& _Other) __GPU + { + unorm_2 _Value1 = *this; + unorm_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_2 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_2 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 rg; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 1 of this unorm_2. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xy() const __GPU { + return unorm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this unorm_2 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_2 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_2 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 gr; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 0 of this unorm_2. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yx() const __GPU { + return unorm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this unorm_2 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + }; + + /// <summary> + /// Represent a short vector of 3 unorm's. + /// </summary> + class unorm_3 + { + public: + typedef unorm value_type; + static const int size = 3; + private: + static const _Short_vector_base_type_id _Base_type_id = _Unorm_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + + public: + /// <summary> + /// Property for accessing element 0 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm x; + /// <summary> + /// Property for accessing element 0 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm r; + + /// <summary> + /// Returns element 0 of this unorm_3. + /// </summary> + /// <returns> + /// Element 0 of this unorm_3. + /// </returns> + unorm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_3. + /// </returns> + unorm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_3. + /// </returns> + unorm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this unorm_3 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_x(unorm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm y; + /// <summary> + /// Property for accessing element 1 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm g; + + /// <summary> + /// Returns element 1 of this unorm_3. + /// </summary> + /// <returns> + /// Element 1 of this unorm_3. + /// </returns> + unorm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_3. + /// </returns> + unorm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_3. + /// </returns> + unorm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this unorm_3 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_y(unorm _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unorm z; + /// <summary> + /// Property for accessing element 2 of this unorm_3 as a unorm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unorm b; + + /// <summary> + /// Returns element 2 of this unorm_3. + /// </summary> + /// <returns> + /// Element 2 of this unorm_3. + /// </returns> + unorm get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this unorm_3. + /// </returns> + unorm& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this unorm_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this unorm_3. + /// </returns> + unorm& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this unorm_3 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_z(unorm _Value) __GPU + { + _M_z = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + unorm_3() __GPU + { + _M_x = unorm(0.0f); + _M_y = unorm(0.0f); + _M_z = unorm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + unorm_3(unorm _V0, unorm _V1, unorm _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + unorm_3(float _V0, float _V1, float _V2) __GPU + { + _M_x = unorm(_V0); + _M_y = unorm(_V1); + _M_z = unorm(_V2); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + unorm_3(unorm _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + } + + explicit unorm_3(float _V) __GPU + { + _M_x = unorm(_V); + _M_y = unorm(_V); + _M_z = unorm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + unorm_3(const unorm_3& _Other) __GPU + { + *this = _Other; + } + + unorm_3& operator=(const unorm_3& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + _M_z = _Other._M_z; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_3(const uint_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_3(const int_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_3(const float_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_3(const norm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_3(const double_3& _Other) __GPU; + + unorm_3& operator++() __GPU + { + unorm_3 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + *this = _Value; + return *this; + } + + unorm_3 operator++(int) __GPU + { + unorm_3 _Result = *this; + ++(*this); + return _Result; + } + + unorm_3& operator--() __GPU + { + unorm_3 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + *this = _Value; + return *this; + } + + unorm_3 operator--(int) __GPU + { + unorm_3 _Result = *this; + --(*this); + return _Result; + } + + unorm_3& operator+=(const unorm_3& _Other) __GPU + { + unorm_3 _Value1 = *this; + unorm_3 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + *this = _Value1; + return *this; + } + + unorm_3& operator-=(const unorm_3& _Other) __GPU + { + unorm_3 _Value1 = *this; + unorm_3 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + *this = _Value1; + return *this; + } + + unorm_3& operator*=(const unorm_3& _Other) __GPU + { + unorm_3 _Value1 = *this; + unorm_3 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + *this = _Value1; + return *this; + } + + unorm_3& operator/=(const unorm_3& _Other) __GPU + { + unorm_3 _Value1 = *this; + unorm_3 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 rg; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 1 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xy() const __GPU { + return unorm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) unorm_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) unorm_2 rb; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 2 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xz() const __GPU { + return unorm_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xz(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 gr; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 0 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yx() const __GPU { + return unorm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) unorm_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) unorm_2 gb; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 2 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yz() const __GPU { + return unorm_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yz(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) unorm_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) unorm_2 br; + + /// <summary> + /// Returns a unorm_2 that is composed of element 2, and element 0 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_zx() const __GPU { + return unorm_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_zx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) unorm_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this unorm_3 as a unorm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) unorm_2 bg; + + /// <summary> + /// Returns a unorm_2 that is composed of element 2, and element 1 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_zy() const __GPU { + return unorm_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this unorm_3 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_zy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) unorm_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) unorm_3 rgb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 1, and element 2 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xyz() const __GPU { + return unorm_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xyz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) unorm_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) unorm_3 rbg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 2, and element 1 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xzy() const __GPU { + return unorm_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xzy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) unorm_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) unorm_3 grb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 0, and element 2 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yxz() const __GPU { + return unorm_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yxz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) unorm_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) unorm_3 gbr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 2, and element 0 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yzx() const __GPU { + return unorm_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yzx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) unorm_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) unorm_3 brg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 0, and element 1 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zxy() const __GPU { + return unorm_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zxy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) unorm_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this unorm_3 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) unorm_3 bgr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 1, and element 0 of this unorm_3. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zyx() const __GPU { + return unorm_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this unorm_3 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zyx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + }; + + /// <summary> + /// Represent a short vector of 4 unorm's. + /// </summary> + class unorm_4 + { + public: + typedef unorm value_type; + static const int size = 4; + private: + static const _Short_vector_base_type_id _Base_type_id = _Unorm_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + value_type _M_w; + + public: + /// <summary> + /// Property for accessing element 0 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm x; + /// <summary> + /// Property for accessing element 0 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) unorm r; + + /// <summary> + /// Returns element 0 of this unorm_4. + /// </summary> + /// <returns> + /// Element 0 of this unorm_4. + /// </returns> + unorm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_4. + /// </returns> + unorm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this unorm_4. + /// </returns> + unorm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this unorm_4 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_x(unorm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm y; + /// <summary> + /// Property for accessing element 1 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) unorm g; + + /// <summary> + /// Returns element 1 of this unorm_4. + /// </summary> + /// <returns> + /// Element 1 of this unorm_4. + /// </returns> + unorm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_4. + /// </returns> + unorm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this unorm_4. + /// </returns> + unorm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this unorm_4 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_y(unorm _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unorm z; + /// <summary> + /// Property for accessing element 2 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) unorm b; + + /// <summary> + /// Returns element 2 of this unorm_4. + /// </summary> + /// <returns> + /// Element 2 of this unorm_4. + /// </returns> + unorm get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this unorm_4. + /// </returns> + unorm& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this unorm_4. + /// </returns> + unorm& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this unorm_4 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_z(unorm _Value) __GPU + { + _M_z = _Value; + } + + /// <summary> + /// Property for accessing element 3 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) unorm w; + /// <summary> + /// Property for accessing element 3 of this unorm_4 as a unorm. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) unorm a; + + /// <summary> + /// Returns element 3 of this unorm_4. + /// </summary> + /// <returns> + /// Element 3 of this unorm_4. + /// </returns> + unorm get_w() const __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this unorm_4. + /// </returns> + unorm& ref_w() __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this unorm_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this unorm_4. + /// </returns> + unorm& ref_a() __GPU { + return _M_w; + } + + /// <summary> + /// Set element 3 of this unorm_4 with a unorm. + /// </summary> + /// <param name="_Value"> + /// a unorm value. + /// </param> + void set_w(unorm _Value) __GPU + { + _M_w = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + unorm_4() __GPU + { + _M_x = unorm(0.0f); + _M_y = unorm(0.0f); + _M_z = unorm(0.0f); + _M_w = unorm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + unorm_4(unorm _V0, unorm _V1, unorm _V2, unorm _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + unorm_4(float _V0, float _V1, float _V2, float _V3) __GPU + { + _M_x = unorm(_V0); + _M_y = unorm(_V1); + _M_z = unorm(_V2); + _M_w = unorm(_V3); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + unorm_4(unorm _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + _M_w = _V; + } + + explicit unorm_4(float _V) __GPU + { + _M_x = unorm(_V); + _M_y = unorm(_V); + _M_z = unorm(_V); + _M_w = unorm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + unorm_4(const unorm_4& _Other) __GPU + { + *this = _Other; + } + + unorm_4& operator=(const unorm_4& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + _M_z = _Other._M_z; + _M_w = _Other._M_w; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_4(const uint_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_4(const int_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_4(const float_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_4(const norm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline unorm_4(const double_4& _Other) __GPU; + + unorm_4& operator++() __GPU + { + unorm_4 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + ++_Value._M_w; + *this = _Value; + return *this; + } + + unorm_4 operator++(int) __GPU + { + unorm_4 _Result = *this; + ++(*this); + return _Result; + } + + unorm_4& operator--() __GPU + { + unorm_4 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + --_Value._M_w; + *this = _Value; + return *this; + } + + unorm_4 operator--(int) __GPU + { + unorm_4 _Result = *this; + --(*this); + return _Result; + } + + unorm_4& operator+=(const unorm_4& _Other) __GPU + { + unorm_4 _Value1 = *this; + unorm_4 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + _Value1.w += _Value2.w; + *this = _Value1; + return *this; + } + + unorm_4& operator-=(const unorm_4& _Other) __GPU + { + unorm_4 _Value1 = *this; + unorm_4 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + _Value1.w -= _Value2.w; + *this = _Value1; + return *this; + } + + unorm_4& operator*=(const unorm_4& _Other) __GPU + { + unorm_4 _Value1 = *this; + unorm_4 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + _Value1.w *= _Value2.w; + *this = _Value1; + return *this; + } + + unorm_4& operator/=(const unorm_4& _Other) __GPU + { + unorm_4 _Value1 = *this; + unorm_4 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + _Value1.w /= _Value2.w; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) unorm_2 rg; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xy() const __GPU { + return unorm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) unorm_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) unorm_2 rb; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xz() const __GPU { + return unorm_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xz(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) unorm_2 xw; + /// <summary> + /// Property for accessing element 0, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) unorm_2 ra; + + /// <summary> + /// Returns a unorm_2 that is composed of element 0, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_xw() const __GPU { + return unorm_2(_M_x,_M_w); + } + + /// <summary> + /// Set element 0, and 3 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_xw(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) unorm_2 gr; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yx() const __GPU { + return unorm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) unorm_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) unorm_2 gb; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yz() const __GPU { + return unorm_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yz(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) unorm_2 yw; + /// <summary> + /// Property for accessing element 1, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) unorm_2 ga; + + /// <summary> + /// Returns a unorm_2 that is composed of element 1, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_yw() const __GPU { + return unorm_2(_M_y,_M_w); + } + + /// <summary> + /// Set element 1, and 3 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_yw(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) unorm_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) unorm_2 br; + + /// <summary> + /// Returns a unorm_2 that is composed of element 2, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_zx() const __GPU { + return unorm_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_zx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) unorm_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) unorm_2 bg; + + /// <summary> + /// Returns a unorm_2 that is composed of element 2, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_zy() const __GPU { + return unorm_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_zy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) unorm_2 zw; + /// <summary> + /// Property for accessing element 2, and 3 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) unorm_2 ba; + + /// <summary> + /// Returns a unorm_2 that is composed of element 2, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_zw() const __GPU { + return unorm_2(_M_z,_M_w); + } + + /// <summary> + /// Set element 2, and 3 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_zw(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) unorm_2 wx; + /// <summary> + /// Property for accessing element 3, and 0 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) unorm_2 ar; + + /// <summary> + /// Returns a unorm_2 that is composed of element 3, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_wx() const __GPU { + return unorm_2(_M_w,_M_x); + } + + /// <summary> + /// Set element 3, and 0 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_wx(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) unorm_2 wy; + /// <summary> + /// Property for accessing element 3, and 1 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) unorm_2 ag; + + /// <summary> + /// Returns a unorm_2 that is composed of element 3, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_wy() const __GPU { + return unorm_2(_M_w,_M_y); + } + + /// <summary> + /// Set element 3, and 1 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_wy(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) unorm_2 wz; + /// <summary> + /// Property for accessing element 3, and 2 of this unorm_4 as a unorm_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) unorm_2 ab; + + /// <summary> + /// Returns a unorm_2 that is composed of element 3, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_2. + /// </returns> + unorm_2 get_wz() const __GPU { + return unorm_2(_M_w,_M_z); + } + + /// <summary> + /// Set element 3, and 2 of this unorm_4 with a unorm_2. + /// </summary> + /// <param name="_Value"> + /// a unorm_2 value. + /// </param> + void set_wz(const unorm_2& _Value) __GPU + { + unorm_2 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) unorm_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) unorm_3 rgb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 1, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xyz() const __GPU { + return unorm_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xyz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) unorm_3 xyw; + /// <summary> + /// Property for accessing element 0, 1, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) unorm_3 rga; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 1, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xyw() const __GPU { + return unorm_3(_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 1, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xyw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) unorm_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) unorm_3 rbg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 2, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xzy() const __GPU { + return unorm_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xzy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) unorm_3 xzw; + /// <summary> + /// Property for accessing element 0, 2, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) unorm_3 rba; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 2, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xzw() const __GPU { + return unorm_3(_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 2, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xzw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) unorm_3 xwy; + /// <summary> + /// Property for accessing element 0, 3, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) unorm_3 rag; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 3, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xwy() const __GPU { + return unorm_3(_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 3, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xwy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) unorm_3 xwz; + /// <summary> + /// Property for accessing element 0, 3, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) unorm_3 rab; + + /// <summary> + /// Returns a unorm_3 that is composed of element 0, element 3, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_xwz() const __GPU { + return unorm_3(_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 3, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_xwz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) unorm_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) unorm_3 grb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 0, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yxz() const __GPU { + return unorm_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yxz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) unorm_3 yxw; + /// <summary> + /// Property for accessing element 1, 0, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) unorm_3 gra; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 0, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yxw() const __GPU { + return unorm_3(_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 0, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yxw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) unorm_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) unorm_3 gbr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 2, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yzx() const __GPU { + return unorm_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yzx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) unorm_3 yzw; + /// <summary> + /// Property for accessing element 1, 2, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) unorm_3 gba; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 2, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_yzw() const __GPU { + return unorm_3(_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 2, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_yzw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) unorm_3 ywx; + /// <summary> + /// Property for accessing element 1, 3, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) unorm_3 gar; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 3, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_ywx() const __GPU { + return unorm_3(_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 3, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_ywx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) unorm_3 ywz; + /// <summary> + /// Property for accessing element 1, 3, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) unorm_3 gab; + + /// <summary> + /// Returns a unorm_3 that is composed of element 1, element 3, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_ywz() const __GPU { + return unorm_3(_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 3, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_ywz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) unorm_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) unorm_3 brg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 0, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zxy() const __GPU { + return unorm_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zxy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) unorm_3 zxw; + /// <summary> + /// Property for accessing element 2, 0, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) unorm_3 bra; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 0, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zxw() const __GPU { + return unorm_3(_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 0, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zxw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) unorm_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) unorm_3 bgr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 1, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zyx() const __GPU { + return unorm_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zyx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) unorm_3 zyw; + /// <summary> + /// Property for accessing element 2, 1, and 3 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) unorm_3 bga; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 1, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zyw() const __GPU { + return unorm_3(_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 1, and 3 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zyw(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) unorm_3 zwx; + /// <summary> + /// Property for accessing element 2, 3, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) unorm_3 bar; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 3, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zwx() const __GPU { + return unorm_3(_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 3, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zwx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) unorm_3 zwy; + /// <summary> + /// Property for accessing element 2, 3, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) unorm_3 bag; + + /// <summary> + /// Returns a unorm_3 that is composed of element 2, element 3, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_zwy() const __GPU { + return unorm_3(_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 3, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_zwy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) unorm_3 wxy; + /// <summary> + /// Property for accessing element 3, 0, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) unorm_3 arg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 0, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wxy() const __GPU { + return unorm_3(_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 0, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wxy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) unorm_3 wxz; + /// <summary> + /// Property for accessing element 3, 0, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) unorm_3 arb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 0, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wxz() const __GPU { + return unorm_3(_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 0, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wxz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) unorm_3 wyx; + /// <summary> + /// Property for accessing element 3, 1, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) unorm_3 agr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 1, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wyx() const __GPU { + return unorm_3(_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 1, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wyx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) unorm_3 wyz; + /// <summary> + /// Property for accessing element 3, 1, and 2 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) unorm_3 agb; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 1, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wyz() const __GPU { + return unorm_3(_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 1, and 2 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wyz(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) unorm_3 wzx; + /// <summary> + /// Property for accessing element 3, 2, and 0 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) unorm_3 abr; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 2, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wzx() const __GPU { + return unorm_3(_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 2, and 0 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wzx(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) unorm_3 wzy; + /// <summary> + /// Property for accessing element 3, 2, and 1 of this unorm_4 as a unorm_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) unorm_3 abg; + + /// <summary> + /// Returns a unorm_3 that is composed of element 3, element 2, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_3. + /// </returns> + unorm_3 get_wzy() const __GPU { + return unorm_3(_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 2, and 1 of this unorm_4 with a unorm_3. + /// </summary> + /// <param name="_Value"> + /// a unorm_3 value. + /// </param> + void set_wzy(const unorm_3& _Value) __GPU + { + unorm_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) unorm_4 xyzw; + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) unorm_4 rgba; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 1, element 2, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xyzw() const __GPU { + return unorm_4(_M_x,_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 1, 2, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xyzw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) unorm_4 xywz; + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) unorm_4 rgab; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 1, element 3, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xywz() const __GPU { + return unorm_4(_M_x,_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 1, 3, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xywz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) unorm_4 xzyw; + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) unorm_4 rbga; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 2, element 1, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xzyw() const __GPU { + return unorm_4(_M_x,_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 2, 1, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xzyw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) unorm_4 xzwy; + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) unorm_4 rbag; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 2, element 3, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xzwy() const __GPU { + return unorm_4(_M_x,_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 2, 3, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xzwy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) unorm_4 xwyz; + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) unorm_4 ragb; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 3, element 1, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xwyz() const __GPU { + return unorm_4(_M_x,_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 3, 1, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xwyz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) unorm_4 xwzy; + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) unorm_4 rabg; + + /// <summary> + /// Returns a unorm_4 that is composed of element 0, element 3, element 2, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_xwzy() const __GPU { + return unorm_4(_M_x,_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 3, 2, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_xwzy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) unorm_4 yxzw; + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) unorm_4 grba; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 0, element 2, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_yxzw() const __GPU { + return unorm_4(_M_y,_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 0, 2, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_yxzw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) unorm_4 yxwz; + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) unorm_4 grab; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 0, element 3, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_yxwz() const __GPU { + return unorm_4(_M_y,_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 0, 3, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_yxwz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) unorm_4 yzxw; + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) unorm_4 gbra; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 2, element 0, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_yzxw() const __GPU { + return unorm_4(_M_y,_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 2, 0, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_yzxw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) unorm_4 yzwx; + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) unorm_4 gbar; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 2, element 3, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_yzwx() const __GPU { + return unorm_4(_M_y,_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 2, 3, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_yzwx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) unorm_4 ywxz; + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) unorm_4 garb; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 3, element 0, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_ywxz() const __GPU { + return unorm_4(_M_y,_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 3, 0, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_ywxz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) unorm_4 ywzx; + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) unorm_4 gabr; + + /// <summary> + /// Returns a unorm_4 that is composed of element 1, element 3, element 2, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_ywzx() const __GPU { + return unorm_4(_M_y,_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 3, 2, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_ywzx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) unorm_4 zxyw; + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) unorm_4 brga; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 0, element 1, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zxyw() const __GPU { + return unorm_4(_M_z,_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 0, 1, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zxyw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) unorm_4 zxwy; + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) unorm_4 brag; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 0, element 3, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zxwy() const __GPU { + return unorm_4(_M_z,_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 0, 3, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zxwy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) unorm_4 zyxw; + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) unorm_4 bgra; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 1, element 0, and element 3 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zyxw() const __GPU { + return unorm_4(_M_z,_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 1, 0, and 3 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zyxw(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) unorm_4 zywx; + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) unorm_4 bgar; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 1, element 3, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zywx() const __GPU { + return unorm_4(_M_z,_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 1, 3, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zywx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) unorm_4 zwxy; + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) unorm_4 barg; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 3, element 0, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zwxy() const __GPU { + return unorm_4(_M_z,_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 3, 0, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zwxy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) unorm_4 zwyx; + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) unorm_4 bagr; + + /// <summary> + /// Returns a unorm_4 that is composed of element 2, element 3, element 1, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_zwyx() const __GPU { + return unorm_4(_M_z,_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 3, 1, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_zwyx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) unorm_4 wxyz; + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) unorm_4 argb; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 0, element 1, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wxyz() const __GPU { + return unorm_4(_M_w,_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 0, 1, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wxyz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) unorm_4 wxzy; + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) unorm_4 arbg; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 0, element 2, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wxzy() const __GPU { + return unorm_4(_M_w,_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 0, 2, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wxzy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) unorm_4 wyxz; + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) unorm_4 agrb; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 1, element 0, and element 2 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wyxz() const __GPU { + return unorm_4(_M_w,_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 1, 0, and 2 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wyxz(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) unorm_4 wyzx; + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) unorm_4 agbr; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 1, element 2, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wyzx() const __GPU { + return unorm_4(_M_w,_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 1, 2, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wyzx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) unorm_4 wzxy; + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) unorm_4 abrg; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 2, element 0, and element 1 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wzxy() const __GPU { + return unorm_4(_M_w,_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 2, 0, and 1 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wzxy(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) unorm_4 wzyx; + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this unorm_4 as a unorm_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) unorm_4 abgr; + + /// <summary> + /// Returns a unorm_4 that is composed of element 3, element 2, element 1, and element 0 of this unorm_4. + /// </summary> + /// <returns> + /// a unorm_4. + /// </returns> + unorm_4 get_wzyx() const __GPU { + return unorm_4(_M_w,_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 2, 1, and 0 of this unorm_4 with a unorm_4. + /// </summary> + /// <param name="_Value"> + /// a unorm_4 value. + /// </param> + void set_wzyx(const unorm_4& _Value) __GPU + { + unorm_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + }; + + /// <summary> + /// Represent a short vector of 2 norm's. + /// </summary> + class norm_2 + { + public: + typedef norm value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Norm_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this norm_2 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm x; + /// <summary> + /// Property for accessing element 0 of this norm_2 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm r; + + /// <summary> + /// Returns element 0 of this norm_2. + /// </summary> + /// <returns> + /// Element 0 of this norm_2. + /// </returns> + norm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_2. + /// </returns> + norm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_2. + /// </returns> + norm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this norm_2 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_x(norm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this norm_2 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm y; + /// <summary> + /// Property for accessing element 1 of this norm_2 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm g; + + /// <summary> + /// Returns element 1 of this norm_2. + /// </summary> + /// <returns> + /// Element 1 of this norm_2. + /// </returns> + norm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_2. + /// </returns> + norm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_2. + /// </returns> + norm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this norm_2 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_y(norm _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + norm_2() __GPU + { + _M_x = norm(0.0f); + _M_y = norm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + norm_2(norm _V0, norm _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + norm_2(float _V0, float _V1) __GPU + { + _M_x = norm(_V0); + _M_y = norm(_V1); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + norm_2(unorm _V0, unorm _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + norm_2(norm _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + explicit norm_2(float _V) __GPU + { + _M_x = norm(_V); + _M_y = norm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + norm_2(const norm_2& _Other) __GPU + { + *this = _Other; + } + + norm_2& operator=(const norm_2& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_2(const uint_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_2(const int_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_2(const float_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_2(const unorm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_2(const double_2& _Other) __GPU; + + norm_2 operator-() const __GPU + { + norm_2 _Value = *this; + return norm_2(-_Value.x, -_Value.y); + } + + norm_2& operator++() __GPU + { + norm_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + norm_2 operator++(int) __GPU + { + norm_2 _Result = *this; + ++(*this); + return _Result; + } + + norm_2& operator--() __GPU + { + norm_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + norm_2 operator--(int) __GPU + { + norm_2 _Result = *this; + --(*this); + return _Result; + } + + norm_2& operator+=(const norm_2& _Other) __GPU + { + norm_2 _Value1 = *this; + norm_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + norm_2& operator-=(const norm_2& _Other) __GPU + { + norm_2 _Value1 = *this; + norm_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + norm_2& operator*=(const norm_2& _Other) __GPU + { + norm_2 _Value1 = *this; + norm_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + norm_2& operator/=(const norm_2& _Other) __GPU + { + norm_2 _Value1 = *this; + norm_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this norm_2 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this norm_2 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 rg; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 1 of this norm_2. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xy() const __GPU { + return norm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this norm_2 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this norm_2 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this norm_2 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 gr; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 0 of this norm_2. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yx() const __GPU { + return norm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this norm_2 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + }; + + /// <summary> + /// Represent a short vector of 3 norm's. + /// </summary> + class norm_3 + { + public: + typedef norm value_type; + static const int size = 3; + private: + static const _Short_vector_base_type_id _Base_type_id = _Norm_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + + public: + /// <summary> + /// Property for accessing element 0 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm x; + /// <summary> + /// Property for accessing element 0 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm r; + + /// <summary> + /// Returns element 0 of this norm_3. + /// </summary> + /// <returns> + /// Element 0 of this norm_3. + /// </returns> + norm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_3. + /// </returns> + norm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_3. + /// </returns> + norm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this norm_3 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_x(norm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm y; + /// <summary> + /// Property for accessing element 1 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm g; + + /// <summary> + /// Returns element 1 of this norm_3. + /// </summary> + /// <returns> + /// Element 1 of this norm_3. + /// </returns> + norm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_3. + /// </returns> + norm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_3. + /// </returns> + norm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this norm_3 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_y(norm _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) norm z; + /// <summary> + /// Property for accessing element 2 of this norm_3 as a norm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) norm b; + + /// <summary> + /// Returns element 2 of this norm_3. + /// </summary> + /// <returns> + /// Element 2 of this norm_3. + /// </returns> + norm get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this norm_3. + /// </returns> + norm& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this norm_3. + /// </summary> + /// <returns> + /// Reference to element 2 of this norm_3. + /// </returns> + norm& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this norm_3 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_z(norm _Value) __GPU + { + _M_z = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + norm_3() __GPU + { + _M_x = norm(0.0f); + _M_y = norm(0.0f); + _M_z = norm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + norm_3(norm _V0, norm _V1, norm _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + norm_3(float _V0, float _V1, float _V2) __GPU + { + _M_x = norm(_V0); + _M_y = norm(_V1); + _M_z = norm(_V2); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + norm_3(unorm _V0, unorm _V1, unorm _V2) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + norm_3(norm _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + } + + explicit norm_3(float _V) __GPU + { + _M_x = norm(_V); + _M_y = norm(_V); + _M_z = norm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + norm_3(const norm_3& _Other) __GPU + { + *this = _Other; + } + + norm_3& operator=(const norm_3& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + _M_z = _Other._M_z; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_3(const uint_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_3(const int_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_3(const float_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_3(const unorm_3& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_3(const double_3& _Other) __GPU; + + norm_3 operator-() const __GPU + { + norm_3 _Value = *this; + return norm_3(-_Value.x, -_Value.y, -_Value.z); + } + + norm_3& operator++() __GPU + { + norm_3 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + *this = _Value; + return *this; + } + + norm_3 operator++(int) __GPU + { + norm_3 _Result = *this; + ++(*this); + return _Result; + } + + norm_3& operator--() __GPU + { + norm_3 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + *this = _Value; + return *this; + } + + norm_3 operator--(int) __GPU + { + norm_3 _Result = *this; + --(*this); + return _Result; + } + + norm_3& operator+=(const norm_3& _Other) __GPU + { + norm_3 _Value1 = *this; + norm_3 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + *this = _Value1; + return *this; + } + + norm_3& operator-=(const norm_3& _Other) __GPU + { + norm_3 _Value1 = *this; + norm_3 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + *this = _Value1; + return *this; + } + + norm_3& operator*=(const norm_3& _Other) __GPU + { + norm_3 _Value1 = *this; + norm_3 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + *this = _Value1; + return *this; + } + + norm_3& operator/=(const norm_3& _Other) __GPU + { + norm_3 _Value1 = *this; + norm_3 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 rg; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 1 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xy() const __GPU { + return norm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) norm_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) norm_2 rb; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 2 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xz() const __GPU { + return norm_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xz(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 gr; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 0 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yx() const __GPU { + return norm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) norm_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) norm_2 gb; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 2 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yz() const __GPU { + return norm_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yz(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) norm_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) norm_2 br; + + /// <summary> + /// Returns a norm_2 that is composed of element 2, and element 0 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_zx() const __GPU { + return norm_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_zx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) norm_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this norm_3 as a norm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) norm_2 bg; + + /// <summary> + /// Returns a norm_2 that is composed of element 2, and element 1 of this norm_3. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_zy() const __GPU { + return norm_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this norm_3 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_zy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) norm_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) norm_3 rgb; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 1, and element 2 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xyz() const __GPU { + return norm_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xyz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) norm_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) norm_3 rbg; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 2, and element 1 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xzy() const __GPU { + return norm_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xzy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) norm_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) norm_3 grb; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 0, and element 2 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yxz() const __GPU { + return norm_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yxz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) norm_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) norm_3 gbr; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 2, and element 0 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yzx() const __GPU { + return norm_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yzx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) norm_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) norm_3 brg; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 0, and element 1 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zxy() const __GPU { + return norm_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zxy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) norm_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this norm_3 as a norm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) norm_3 bgr; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 1, and element 0 of this norm_3. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zyx() const __GPU { + return norm_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this norm_3 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zyx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + }; + + /// <summary> + /// Represent a short vector of 4 norm's. + /// </summary> + class norm_4 + { + public: + typedef norm value_type; + static const int size = 4; + private: + static const _Short_vector_base_type_id _Base_type_id = _Norm_type; + private: + value_type _M_x; + value_type _M_y; + value_type _M_z; + value_type _M_w; + + public: + /// <summary> + /// Property for accessing element 0 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm x; + /// <summary> + /// Property for accessing element 0 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) norm r; + + /// <summary> + /// Returns element 0 of this norm_4. + /// </summary> + /// <returns> + /// Element 0 of this norm_4. + /// </returns> + norm get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_4. + /// </returns> + norm& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 0 of this norm_4. + /// </returns> + norm& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this norm_4 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_x(norm _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm y; + /// <summary> + /// Property for accessing element 1 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) norm g; + + /// <summary> + /// Returns element 1 of this norm_4. + /// </summary> + /// <returns> + /// Element 1 of this norm_4. + /// </returns> + norm get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_4. + /// </returns> + norm& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 1 of this norm_4. + /// </returns> + norm& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this norm_4 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_y(norm _Value) __GPU + { + _M_y = _Value; + } + + /// <summary> + /// Property for accessing element 2 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) norm z; + /// <summary> + /// Property for accessing element 2 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_z, put=set_z) ) norm b; + + /// <summary> + /// Returns element 2 of this norm_4. + /// </summary> + /// <returns> + /// Element 2 of this norm_4. + /// </returns> + norm get_z() const __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this norm_4. + /// </returns> + norm& ref_z() __GPU { + return _M_z; + } + + /// <summary> + /// Returns reference to element 2 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 2 of this norm_4. + /// </returns> + norm& ref_b() __GPU { + return _M_z; + } + + /// <summary> + /// Set element 2 of this norm_4 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_z(norm _Value) __GPU + { + _M_z = _Value; + } + + /// <summary> + /// Property for accessing element 3 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) norm w; + /// <summary> + /// Property for accessing element 3 of this norm_4 as a norm. + /// </summary> + __declspec( property( get=get_w, put=set_w) ) norm a; + + /// <summary> + /// Returns element 3 of this norm_4. + /// </summary> + /// <returns> + /// Element 3 of this norm_4. + /// </returns> + norm get_w() const __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this norm_4. + /// </returns> + norm& ref_w() __GPU { + return _M_w; + } + + /// <summary> + /// Returns reference to element 3 of this norm_4. + /// </summary> + /// <returns> + /// Reference to element 3 of this norm_4. + /// </returns> + norm& ref_a() __GPU { + return _M_w; + } + + /// <summary> + /// Set element 3 of this norm_4 with a norm. + /// </summary> + /// <param name="_Value"> + /// a norm value. + /// </param> + void set_w(norm _Value) __GPU + { + _M_w = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + norm_4() __GPU + { + _M_x = norm(0.0f); + _M_y = norm(0.0f); + _M_z = norm(0.0f); + _M_w = norm(0.0f); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + norm_4(norm _V0, norm _V1, norm _V2, norm _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + norm_4(float _V0, float _V1, float _V2, float _V3) __GPU + { + _M_x = norm(_V0); + _M_y = norm(_V1); + _M_z = norm(_V2); + _M_w = norm(_V3); + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + /// <param name="_V2"> + /// The value to initialize element 2. + /// </param> + /// <param name="_V3"> + /// The value to initialize element 3. + /// </param> + norm_4(unorm _V0, unorm _V1, unorm _V2, unorm _V3) __GPU + { + _M_x = _V0; + _M_y = _V1; + _M_z = _V2; + _M_w = _V3; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + norm_4(norm _V) __GPU + { + _M_x = _V; + _M_y = _V; + _M_z = _V; + _M_w = _V; + } + + explicit norm_4(float _V) __GPU + { + _M_x = norm(_V); + _M_y = norm(_V); + _M_z = norm(_V); + _M_w = norm(_V); + } + + /// <summary> + /// Copy constructor. + /// </summary> + /// <param name="_Other"> + /// The object to copy from. + /// </param> + norm_4(const norm_4& _Other) __GPU + { + *this = _Other; + } + + norm_4& operator=(const norm_4& _Other) __GPU + { + _M_x = _Other._M_x; + _M_y = _Other._M_y; + _M_z = _Other._M_z; + _M_w = _Other._M_w; + return *this; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_4(const uint_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_4(const int_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_4(const float_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_4(const unorm_4& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline norm_4(const double_4& _Other) __GPU; + + norm_4 operator-() const __GPU + { + norm_4 _Value = *this; + return norm_4(-_Value.x, -_Value.y, -_Value.z, -_Value.w); + } + + norm_4& operator++() __GPU + { + norm_4 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + ++_Value._M_z; + ++_Value._M_w; + *this = _Value; + return *this; + } + + norm_4 operator++(int) __GPU + { + norm_4 _Result = *this; + ++(*this); + return _Result; + } + + norm_4& operator--() __GPU + { + norm_4 _Value = *this; + --_Value._M_x; + --_Value._M_y; + --_Value._M_z; + --_Value._M_w; + *this = _Value; + return *this; + } + + norm_4 operator--(int) __GPU + { + norm_4 _Result = *this; + --(*this); + return _Result; + } + + norm_4& operator+=(const norm_4& _Other) __GPU + { + norm_4 _Value1 = *this; + norm_4 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + _Value1.z += _Value2.z; + _Value1.w += _Value2.w; + *this = _Value1; + return *this; + } + + norm_4& operator-=(const norm_4& _Other) __GPU + { + norm_4 _Value1 = *this; + norm_4 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + _Value1.z -= _Value2.z; + _Value1.w -= _Value2.w; + *this = _Value1; + return *this; + } + + norm_4& operator*=(const norm_4& _Other) __GPU + { + norm_4 _Value1 = *this; + norm_4 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + _Value1.z *= _Value2.z; + _Value1.w *= _Value2.w; + *this = _Value1; + return *this; + } + + norm_4& operator/=(const norm_4& _Other) __GPU + { + norm_4 _Value1 = *this; + norm_4 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + _Value1.z /= _Value2.z; + _Value1.w /= _Value2.w; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) norm_2 rg; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xy() const __GPU { + return norm_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) norm_2 xz; + /// <summary> + /// Property for accessing element 0, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xz, put=set_xz) ) norm_2 rb; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xz() const __GPU { + return norm_2(_M_x,_M_z); + } + + /// <summary> + /// Set element 0, and 2 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xz(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) norm_2 xw; + /// <summary> + /// Property for accessing element 0, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_xw, put=set_xw) ) norm_2 ra; + + /// <summary> + /// Returns a norm_2 that is composed of element 0, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_xw() const __GPU { + return norm_2(_M_x,_M_w); + } + + /// <summary> + /// Set element 0, and 3 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_xw(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) norm_2 gr; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yx() const __GPU { + return norm_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) norm_2 yz; + /// <summary> + /// Property for accessing element 1, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yz, put=set_yz) ) norm_2 gb; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yz() const __GPU { + return norm_2(_M_y,_M_z); + } + + /// <summary> + /// Set element 1, and 2 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yz(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) norm_2 yw; + /// <summary> + /// Property for accessing element 1, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_yw, put=set_yw) ) norm_2 ga; + + /// <summary> + /// Returns a norm_2 that is composed of element 1, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_yw() const __GPU { + return norm_2(_M_y,_M_w); + } + + /// <summary> + /// Set element 1, and 3 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_yw(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) norm_2 zx; + /// <summary> + /// Property for accessing element 2, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zx, put=set_zx) ) norm_2 br; + + /// <summary> + /// Returns a norm_2 that is composed of element 2, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_zx() const __GPU { + return norm_2(_M_z,_M_x); + } + + /// <summary> + /// Set element 2, and 0 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_zx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) norm_2 zy; + /// <summary> + /// Property for accessing element 2, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zy, put=set_zy) ) norm_2 bg; + + /// <summary> + /// Returns a norm_2 that is composed of element 2, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_zy() const __GPU { + return norm_2(_M_z,_M_y); + } + + /// <summary> + /// Set element 2, and 1 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_zy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 2, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) norm_2 zw; + /// <summary> + /// Property for accessing element 2, and 3 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_zw, put=set_zw) ) norm_2 ba; + + /// <summary> + /// Returns a norm_2 that is composed of element 2, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_zw() const __GPU { + return norm_2(_M_z,_M_w); + } + + /// <summary> + /// Set element 2, and 3 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_zw(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) norm_2 wx; + /// <summary> + /// Property for accessing element 3, and 0 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wx, put=set_wx) ) norm_2 ar; + + /// <summary> + /// Returns a norm_2 that is composed of element 3, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_wx() const __GPU { + return norm_2(_M_w,_M_x); + } + + /// <summary> + /// Set element 3, and 0 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_wx(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) norm_2 wy; + /// <summary> + /// Property for accessing element 3, and 1 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wy, put=set_wy) ) norm_2 ag; + + /// <summary> + /// Returns a norm_2 that is composed of element 3, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_wy() const __GPU { + return norm_2(_M_w,_M_y); + } + + /// <summary> + /// Set element 3, and 1 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_wy(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 3, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) norm_2 wz; + /// <summary> + /// Property for accessing element 3, and 2 of this norm_4 as a norm_2. + /// </summary> + __declspec( property( get=get_wz, put=set_wz) ) norm_2 ab; + + /// <summary> + /// Returns a norm_2 that is composed of element 3, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_2. + /// </returns> + norm_2 get_wz() const __GPU { + return norm_2(_M_w,_M_z); + } + + /// <summary> + /// Set element 3, and 2 of this norm_4 with a norm_2. + /// </summary> + /// <param name="_Value"> + /// a norm_2 value. + /// </param> + void set_wz(const norm_2& _Value) __GPU + { + norm_2 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + } + + /// <summary> + /// Property for accessing element 0, 1, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) norm_3 xyz; + /// <summary> + /// Property for accessing element 0, 1, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xyz, put=set_xyz) ) norm_3 rgb; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 1, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xyz() const __GPU { + return norm_3(_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 1, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xyz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) norm_3 xyw; + /// <summary> + /// Property for accessing element 0, 1, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xyw, put=set_xyw) ) norm_3 rga; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 1, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xyw() const __GPU { + return norm_3(_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 1, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xyw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) norm_3 xzy; + /// <summary> + /// Property for accessing element 0, 2, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xzy, put=set_xzy) ) norm_3 rbg; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 2, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xzy() const __GPU { + return norm_3(_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 2, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xzy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 2, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) norm_3 xzw; + /// <summary> + /// Property for accessing element 0, 2, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xzw, put=set_xzw) ) norm_3 rba; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 2, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xzw() const __GPU { + return norm_3(_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 2, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xzw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) norm_3 xwy; + /// <summary> + /// Property for accessing element 0, 3, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xwy, put=set_xwy) ) norm_3 rag; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 3, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xwy() const __GPU { + return norm_3(_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 3, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xwy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 3, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) norm_3 xwz; + /// <summary> + /// Property for accessing element 0, 3, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_xwz, put=set_xwz) ) norm_3 rab; + + /// <summary> + /// Returns a norm_3 that is composed of element 0, element 3, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_xwz() const __GPU { + return norm_3(_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 3, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_xwz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) norm_3 yxz; + /// <summary> + /// Property for accessing element 1, 0, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yxz, put=set_yxz) ) norm_3 grb; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 0, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yxz() const __GPU { + return norm_3(_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 0, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yxz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 0, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) norm_3 yxw; + /// <summary> + /// Property for accessing element 1, 0, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yxw, put=set_yxw) ) norm_3 gra; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 0, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yxw() const __GPU { + return norm_3(_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 0, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yxw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) norm_3 yzx; + /// <summary> + /// Property for accessing element 1, 2, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yzx, put=set_yzx) ) norm_3 gbr; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 2, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yzx() const __GPU { + return norm_3(_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 2, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yzx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 2, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) norm_3 yzw; + /// <summary> + /// Property for accessing element 1, 2, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_yzw, put=set_yzw) ) norm_3 gba; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 2, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_yzw() const __GPU { + return norm_3(_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 2, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_yzw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) norm_3 ywx; + /// <summary> + /// Property for accessing element 1, 3, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_ywx, put=set_ywx) ) norm_3 gar; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 3, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_ywx() const __GPU { + return norm_3(_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 3, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_ywx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 1, 3, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) norm_3 ywz; + /// <summary> + /// Property for accessing element 1, 3, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_ywz, put=set_ywz) ) norm_3 gab; + + /// <summary> + /// Returns a norm_3 that is composed of element 1, element 3, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_ywz() const __GPU { + return norm_3(_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 3, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_ywz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) norm_3 zxy; + /// <summary> + /// Property for accessing element 2, 0, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zxy, put=set_zxy) ) norm_3 brg; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 0, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zxy() const __GPU { + return norm_3(_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 0, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zxy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 0, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) norm_3 zxw; + /// <summary> + /// Property for accessing element 2, 0, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zxw, put=set_zxw) ) norm_3 bra; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 0, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zxw() const __GPU { + return norm_3(_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 0, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zxw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) norm_3 zyx; + /// <summary> + /// Property for accessing element 2, 1, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zyx, put=set_zyx) ) norm_3 bgr; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 1, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zyx() const __GPU { + return norm_3(_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 1, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zyx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 1, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) norm_3 zyw; + /// <summary> + /// Property for accessing element 2, 1, and 3 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zyw, put=set_zyw) ) norm_3 bga; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 1, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zyw() const __GPU { + return norm_3(_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 1, and 3 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zyw(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) norm_3 zwx; + /// <summary> + /// Property for accessing element 2, 3, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zwx, put=set_zwx) ) norm_3 bar; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 3, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zwx() const __GPU { + return norm_3(_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 3, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zwx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 2, 3, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) norm_3 zwy; + /// <summary> + /// Property for accessing element 2, 3, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_zwy, put=set_zwy) ) norm_3 bag; + + /// <summary> + /// Returns a norm_3 that is composed of element 2, element 3, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_zwy() const __GPU { + return norm_3(_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 3, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_zwy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) norm_3 wxy; + /// <summary> + /// Property for accessing element 3, 0, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wxy, put=set_wxy) ) norm_3 arg; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 0, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wxy() const __GPU { + return norm_3(_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 0, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wxy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 0, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) norm_3 wxz; + /// <summary> + /// Property for accessing element 3, 0, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wxz, put=set_wxz) ) norm_3 arb; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 0, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wxz() const __GPU { + return norm_3(_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 0, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wxz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) norm_3 wyx; + /// <summary> + /// Property for accessing element 3, 1, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wyx, put=set_wyx) ) norm_3 agr; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 1, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wyx() const __GPU { + return norm_3(_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 1, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wyx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 1, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) norm_3 wyz; + /// <summary> + /// Property for accessing element 3, 1, and 2 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wyz, put=set_wyz) ) norm_3 agb; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 1, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wyz() const __GPU { + return norm_3(_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 1, and 2 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wyz(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) norm_3 wzx; + /// <summary> + /// Property for accessing element 3, 2, and 0 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wzx, put=set_wzx) ) norm_3 abr; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 2, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wzx() const __GPU { + return norm_3(_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 2, and 0 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wzx(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + } + + /// <summary> + /// Property for accessing element 3, 2, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) norm_3 wzy; + /// <summary> + /// Property for accessing element 3, 2, and 1 of this norm_4 as a norm_3. + /// </summary> + __declspec( property( get=get_wzy, put=set_wzy) ) norm_3 abg; + + /// <summary> + /// Returns a norm_3 that is composed of element 3, element 2, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_3. + /// </returns> + norm_3 get_wzy() const __GPU { + return norm_3(_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 2, and 1 of this norm_4 with a norm_3. + /// </summary> + /// <param name="_Value"> + /// a norm_3 value. + /// </param> + void set_wzy(const norm_3& _Value) __GPU + { + norm_3 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + } + + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) norm_4 xyzw; + /// <summary> + /// Property for accessing element 0, 1, 2, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xyzw, put=set_xyzw) ) norm_4 rgba; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 1, element 2, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xyzw() const __GPU { + return norm_4(_M_x,_M_y,_M_z,_M_w); + } + + /// <summary> + /// Set element 0, 1, 2, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xyzw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) norm_4 xywz; + /// <summary> + /// Property for accessing element 0, 1, 3, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xywz, put=set_xywz) ) norm_4 rgab; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 1, element 3, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xywz() const __GPU { + return norm_4(_M_x,_M_y,_M_w,_M_z); + } + + /// <summary> + /// Set element 0, 1, 3, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xywz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) norm_4 xzyw; + /// <summary> + /// Property for accessing element 0, 2, 1, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xzyw, put=set_xzyw) ) norm_4 rbga; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 2, element 1, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xzyw() const __GPU { + return norm_4(_M_x,_M_z,_M_y,_M_w); + } + + /// <summary> + /// Set element 0, 2, 1, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xzyw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) norm_4 xzwy; + /// <summary> + /// Property for accessing element 0, 2, 3, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xzwy, put=set_xzwy) ) norm_4 rbag; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 2, element 3, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xzwy() const __GPU { + return norm_4(_M_x,_M_z,_M_w,_M_y); + } + + /// <summary> + /// Set element 0, 2, 3, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xzwy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) norm_4 xwyz; + /// <summary> + /// Property for accessing element 0, 3, 1, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xwyz, put=set_xwyz) ) norm_4 ragb; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 3, element 1, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xwyz() const __GPU { + return norm_4(_M_x,_M_w,_M_y,_M_z); + } + + /// <summary> + /// Set element 0, 3, 1, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xwyz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) norm_4 xwzy; + /// <summary> + /// Property for accessing element 0, 3, 2, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_xwzy, put=set_xwzy) ) norm_4 rabg; + + /// <summary> + /// Returns a norm_4 that is composed of element 0, element 3, element 2, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_xwzy() const __GPU { + return norm_4(_M_x,_M_w,_M_z,_M_y); + } + + /// <summary> + /// Set element 0, 3, 2, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_xwzy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_x = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) norm_4 yxzw; + /// <summary> + /// Property for accessing element 1, 0, 2, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yxzw, put=set_yxzw) ) norm_4 grba; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 0, element 2, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_yxzw() const __GPU { + return norm_4(_M_y,_M_x,_M_z,_M_w); + } + + /// <summary> + /// Set element 1, 0, 2, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_yxzw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) norm_4 yxwz; + /// <summary> + /// Property for accessing element 1, 0, 3, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yxwz, put=set_yxwz) ) norm_4 grab; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 0, element 3, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_yxwz() const __GPU { + return norm_4(_M_y,_M_x,_M_w,_M_z); + } + + /// <summary> + /// Set element 1, 0, 3, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_yxwz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) norm_4 yzxw; + /// <summary> + /// Property for accessing element 1, 2, 0, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yzxw, put=set_yzxw) ) norm_4 gbra; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 2, element 0, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_yzxw() const __GPU { + return norm_4(_M_y,_M_z,_M_x,_M_w); + } + + /// <summary> + /// Set element 1, 2, 0, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_yzxw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) norm_4 yzwx; + /// <summary> + /// Property for accessing element 1, 2, 3, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_yzwx, put=set_yzwx) ) norm_4 gbar; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 2, element 3, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_yzwx() const __GPU { + return norm_4(_M_y,_M_z,_M_w,_M_x); + } + + /// <summary> + /// Set element 1, 2, 3, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_yzwx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_z = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) norm_4 ywxz; + /// <summary> + /// Property for accessing element 1, 3, 0, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_ywxz, put=set_ywxz) ) norm_4 garb; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 3, element 0, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_ywxz() const __GPU { + return norm_4(_M_y,_M_w,_M_x,_M_z); + } + + /// <summary> + /// Set element 1, 3, 0, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_ywxz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) norm_4 ywzx; + /// <summary> + /// Property for accessing element 1, 3, 2, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_ywzx, put=set_ywzx) ) norm_4 gabr; + + /// <summary> + /// Returns a norm_4 that is composed of element 1, element 3, element 2, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_ywzx() const __GPU { + return norm_4(_M_y,_M_w,_M_z,_M_x); + } + + /// <summary> + /// Set element 1, 3, 2, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_ywzx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_y = _Val.x; + _M_w = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) norm_4 zxyw; + /// <summary> + /// Property for accessing element 2, 0, 1, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zxyw, put=set_zxyw) ) norm_4 brga; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 0, element 1, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zxyw() const __GPU { + return norm_4(_M_z,_M_x,_M_y,_M_w); + } + + /// <summary> + /// Set element 2, 0, 1, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zxyw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) norm_4 zxwy; + /// <summary> + /// Property for accessing element 2, 0, 3, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zxwy, put=set_zxwy) ) norm_4 brag; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 0, element 3, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zxwy() const __GPU { + return norm_4(_M_z,_M_x,_M_w,_M_y); + } + + /// <summary> + /// Set element 2, 0, 3, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zxwy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_x = _Val.y; + _M_w = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) norm_4 zyxw; + /// <summary> + /// Property for accessing element 2, 1, 0, and 3 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zyxw, put=set_zyxw) ) norm_4 bgra; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 1, element 0, and element 3 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zyxw() const __GPU { + return norm_4(_M_z,_M_y,_M_x,_M_w); + } + + /// <summary> + /// Set element 2, 1, 0, and 3 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zyxw(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_w = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) norm_4 zywx; + /// <summary> + /// Property for accessing element 2, 1, 3, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zywx, put=set_zywx) ) norm_4 bgar; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 1, element 3, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zywx() const __GPU { + return norm_4(_M_z,_M_y,_M_w,_M_x); + } + + /// <summary> + /// Set element 2, 1, 3, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zywx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_y = _Val.y; + _M_w = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) norm_4 zwxy; + /// <summary> + /// Property for accessing element 2, 3, 0, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zwxy, put=set_zwxy) ) norm_4 barg; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 3, element 0, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zwxy() const __GPU { + return norm_4(_M_z,_M_w,_M_x,_M_y); + } + + /// <summary> + /// Set element 2, 3, 0, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zwxy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) norm_4 zwyx; + /// <summary> + /// Property for accessing element 2, 3, 1, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_zwyx, put=set_zwyx) ) norm_4 bagr; + + /// <summary> + /// Returns a norm_4 that is composed of element 2, element 3, element 1, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_zwyx() const __GPU { + return norm_4(_M_z,_M_w,_M_y,_M_x); + } + + /// <summary> + /// Set element 2, 3, 1, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_zwyx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_z = _Val.x; + _M_w = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) norm_4 wxyz; + /// <summary> + /// Property for accessing element 3, 0, 1, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wxyz, put=set_wxyz) ) norm_4 argb; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 0, element 1, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wxyz() const __GPU { + return norm_4(_M_w,_M_x,_M_y,_M_z); + } + + /// <summary> + /// Set element 3, 0, 1, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wxyz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_y = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) norm_4 wxzy; + /// <summary> + /// Property for accessing element 3, 0, 2, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wxzy, put=set_wxzy) ) norm_4 arbg; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 0, element 2, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wxzy() const __GPU { + return norm_4(_M_w,_M_x,_M_z,_M_y); + } + + /// <summary> + /// Set element 3, 0, 2, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wxzy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_x = _Val.y; + _M_z = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) norm_4 wyxz; + /// <summary> + /// Property for accessing element 3, 1, 0, and 2 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wyxz, put=set_wyxz) ) norm_4 agrb; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 1, element 0, and element 2 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wyxz() const __GPU { + return norm_4(_M_w,_M_y,_M_x,_M_z); + } + + /// <summary> + /// Set element 3, 1, 0, and 2 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wyxz(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_x = _Val.z; + _M_z = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) norm_4 wyzx; + /// <summary> + /// Property for accessing element 3, 1, 2, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wyzx, put=set_wyzx) ) norm_4 agbr; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 1, element 2, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wyzx() const __GPU { + return norm_4(_M_w,_M_y,_M_z,_M_x); + } + + /// <summary> + /// Set element 3, 1, 2, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wyzx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_y = _Val.y; + _M_z = _Val.z; + _M_x = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) norm_4 wzxy; + /// <summary> + /// Property for accessing element 3, 2, 0, and 1 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wzxy, put=set_wzxy) ) norm_4 abrg; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 2, element 0, and element 1 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wzxy() const __GPU { + return norm_4(_M_w,_M_z,_M_x,_M_y); + } + + /// <summary> + /// Set element 3, 2, 0, and 1 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wzxy(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_x = _Val.z; + _M_y = _Val.w; + } + + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) norm_4 wzyx; + /// <summary> + /// Property for accessing element 3, 2, 1, and 0 of this norm_4 as a norm_4. + /// </summary> + __declspec( property( get=get_wzyx, put=set_wzyx) ) norm_4 abgr; + + /// <summary> + /// Returns a norm_4 that is composed of element 3, element 2, element 1, and element 0 of this norm_4. + /// </summary> + /// <returns> + /// a norm_4. + /// </returns> + norm_4 get_wzyx() const __GPU { + return norm_4(_M_w,_M_z,_M_y,_M_x); + } + + /// <summary> + /// Set element 3, 2, 1, and 0 of this norm_4 with a norm_4. + /// </summary> + /// <param name="_Value"> + /// a norm_4 value. + /// </param> + void set_wzyx(const norm_4& _Value) __GPU + { + norm_4 _Val = _Value; + _M_w = _Val.x; + _M_z = _Val.y; + _M_y = _Val.z; + _M_x = _Val.w; + } + + }; + + /// <summary> + /// Represent a short vector of 2 double's. + /// </summary> + class double_2 + { + public: + typedef double value_type; + static const int size = 2; + private: + static const _Short_vector_base_type_id _Base_type_id = _Double_type; + private: + value_type _M_x; + value_type _M_y; + + public: + /// <summary> + /// Property for accessing element 0 of this double_2 as a double. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) double x; + /// <summary> + /// Property for accessing element 0 of this double_2 as a double. + /// </summary> + __declspec( property( get=get_x, put=set_x) ) double r; + + /// <summary> + /// Returns element 0 of this double_2. + /// </summary> + /// <returns> + /// Element 0 of this double_2. + /// </returns> + double get_x() const __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this double_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this double_2. + /// </returns> + double& ref_x() __GPU { + return _M_x; + } + + /// <summary> + /// Returns reference to element 0 of this double_2. + /// </summary> + /// <returns> + /// Reference to element 0 of this double_2. + /// </returns> + double& ref_r() __GPU { + return _M_x; + } + + /// <summary> + /// Set element 0 of this double_2 with a double. + /// </summary> + /// <param name="_Value"> + /// a double value. + /// </param> + void set_x(double _Value) __GPU + { + _M_x = _Value; + } + + /// <summary> + /// Property for accessing element 1 of this double_2 as a double. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) double y; + /// <summary> + /// Property for accessing element 1 of this double_2 as a double. + /// </summary> + __declspec( property( get=get_y, put=set_y) ) double g; + + /// <summary> + /// Returns element 1 of this double_2. + /// </summary> + /// <returns> + /// Element 1 of this double_2. + /// </returns> + double get_y() const __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this double_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this double_2. + /// </returns> + double& ref_y() __GPU { + return _M_y; + } + + /// <summary> + /// Returns reference to element 1 of this double_2. + /// </summary> + /// <returns> + /// Reference to element 1 of this double_2. + /// </returns> + double& ref_g() __GPU { + return _M_y; + } + + /// <summary> + /// Set element 1 of this double_2 with a double. + /// </summary> + /// <param name="_Value"> + /// a double value. + /// </param> + void set_y(double _Value) __GPU + { + _M_y = _Value; + } + + public: + /// <summary> + /// Default constructor, initializes all elements with 0. + /// </summary> + double_2() __GPU + { + _M_x = 0; + _M_y = 0; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V0"> + /// The value to initialize element 0. + /// </param> + /// <param name="_V1"> + /// The value to initialize element 1. + /// </param> + double_2(double _V0, double _V1) __GPU + { + _M_x = _V0; + _M_y = _V1; + } + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="_V"> + /// The value for initialization. + /// </param> + double_2(double _V) __GPU + { + _M_x = _V; + _M_y = _V; + } + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline double_2(const uint_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline double_2(const int_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline double_2(const float_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline double_2(const unorm_2& _Other) __GPU; + + /// <summary> + /// Constructor. + /// Each element is initialized by casting from the corresponding element in _Other. + /// </summary> + /// <param name="_Other"> + /// The object used to initialize. + /// </param> + explicit inline double_2(const norm_2& _Other) __GPU; + + double_2 operator-() const __GPU + { + double_2 _Value = *this; + return double_2(-_Value.x, -_Value.y); + } + + double_2& operator++() __GPU + { + double_2 _Value = *this; + ++_Value._M_x; + ++_Value._M_y; + *this = _Value; + return *this; + } + + double_2 operator++(int) __GPU + { + double_2 _Result = *this; + ++(*this); + return _Result; + } + + double_2& operator--() __GPU + { + double_2 _Value = *this; + --_Value._M_x; + --_Value._M_y; + *this = _Value; + return *this; + } + + double_2 operator--(int) __GPU + { + double_2 _Result = *this; + --(*this); + return _Result; + } + + double_2& operator+=(const double_2& _Other) __GPU + { + double_2 _Value1 = *this; + double_2 _Value2 = _Other; + _Value1.x += _Value2.x; + _Value1.y += _Value2.y; + *this = _Value1; + return *this; + } + + double_2& operator-=(const double_2& _Other) __GPU + { + double_2 _Value1 = *this; + double_2 _Value2 = _Other; + _Value1.x -= _Value2.x; + _Value1.y -= _Value2.y; + *this = _Value1; + return *this; + } + + double_2& operator*=(const double_2& _Other) __GPU + { + double_2 _Value1 = *this; + double_2 _Value2 = _Other; + _Value1.x *= _Value2.x; + _Value1.y *= _Value2.y; + *this = _Value1; + return *this; + } + + double_2& operator/=(const double_2& _Other) __GPU + { + double_2 _Value1 = *this; + double_2 _Value2 = _Other; + _Value1.x /= _Value2.x; + _Value1.y /= _Value2.y; + *this = _Value1; + return *this; + } + + public: + /// <summary> + /// Property for accessing element 0, and 1 of this double_2 as a double_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) double_2 xy; + /// <summary> + /// Property for accessing element 0, and 1 of this double_2 as a double_2. + /// </summary> + __declspec( property( get=get_xy, put=set_xy) ) double_2 rg; + + /// <summary> + /// Returns a double_2 that is composed of element 0, and element 1 of this double_2. + /// </summary> + /// <returns> + /// a double_2. + /// </returns> + double_2 get_xy() const __GPU { + return double_2(_M_x,_M_y); + } + + /// <summary> + /// Set element 0, and 1 of this double_2 with a double_2. + /// </summary> + /// <param name="_Value"> + /// a double_2 value. + /// </param> + void set_xy(const double_2& _Value) __GPU + { + double_2 _Val = _Value; + _M_x = _Val.x; + _M_y = _Val.y; + } + + /// <summary> + /// Property for accessing element 1, and 0 of this double_2 as a double_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) double_2 yx; + /// <summary> + /// Property for accessing element 1, and 0 of this double_2 as a double_2. + /// </summary> + __declspec( property( get=get_yx, put=set_yx) ) double_2 gr; + + /// <summary> + /// Returns a double_2 that is composed of element 1, and element 0 of this double_2. + /// </summary> + /// <returns> + /// a double_2. + /// </returns> + double_2 get_yx() const __GPU { + return double_2(_M_y,_M_x); + } + + /// <summary> + /// Set element 1, and 0 of this double_2 with a double_2. + /// </summary> + /// <param name="_Value"> + /// a double_2 value. + /// </param> + void set_yx(const